Skip to contentSkip to conversation

fsck.f2fs: fix incorrect parent blkaddr when adding lost dots

PATCH In review Sheng Yong via Linux-f2fs-devel 1 participant 2 messages Oct 24, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsck.f2fs: fix incorrect parent blkaddr when adding lost dots

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.

---
 fsck/fsck.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fsck/fsck.c +2 -3
index 18587fe2c973..ab3ede191449 100644
@@ -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)
Signature · 8 lines
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
author Reviewed-by Chao Yu on v1 1/1
#1 lore raw
Quoted 7 lines · Sheng Yong

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.

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel