diff mbox series

[f2fs-dev] fsck.f2fs: fix incorrect parent blkaddr when adding lost dots

Message ID 20241024033641.517015-1-shengyong@oppo.com (mailing list archive)
State New
Headers show
Series [f2fs-dev] fsck.f2fs: fix incorrect parent blkaddr when adding lost dots | expand

Commit Message

Sheng Yong Oct. 24, 2024, 3:36 a.m. UTC
If dot or dotdot is lost, fsck tries to add a new dentry by
f2fs_add_link(). The blkaddr of the directory inode should be
passed to it in order to update the dirty inode at the right
place. This patch fixes the uninitialized `blkaddr' to avoid
corrupting f2fs image.

Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
 fsck/fsck.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Chao Yu Oct. 24, 2024, 10:55 a.m. UTC | #1
On 2024/10/24 11:36, Sheng Yong wrote:
> If dot or dotdot is lost, fsck tries to add a new dentry by
> f2fs_add_link(). The blkaddr of the directory inode should be
> passed to it in order to update the dirty inode at the right
> place. This patch fixes the uninitialized `blkaddr' to avoid
> corrupting f2fs image.
> 
> Signed-off-by: Sheng Yong <shengyong@oppo.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,
diff mbox series

Patch

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 18587fe2c973..ab3ede191449 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1311,7 +1311,6 @@  skip_blkcnt_fix:
 					nid, child.dot, child.dotdot);
 			if (c.fix_on) {
 				umode_t mode = le16_to_cpu(node_blk->i.i_mode);
-				block_t blkaddr;
 
 				ret = convert_inline_dentry(sbi, node_blk,
 								&ni->blk_addr);
@@ -1326,7 +1325,7 @@  skip_blkcnt_fix:
 					ret = f2fs_add_link(sbi, node_blk,
 						(const unsigned char *)name,
 						1, nid, map_de_type(mode),
-						&blkaddr, 0);
+						&ni->blk_addr, 0);
 					FIX_MSG("add missing '%s' dirent in ino: %u, pino: %u, ret:%d",
 						name, nid, child_d->p_ino, ret);
 					if (ret)
@@ -1340,7 +1339,7 @@  skip_blkcnt_fix:
 						(const unsigned char *)name,
 						2, child_d->p_ino,
 						map_de_type(mode),
-						&blkaddr, 0);
+						&ni->blk_addr, 0);
 					FIX_MSG("add missing '%s' dirent in ino: %u, pino: %u, ret:%d",
 						name, nid, child_d->p_ino, ret);
 					if (ret)