Skip to contentSkip to conversation

f2fs: fix error path of f2fs_create_flush_cmd_control()

PATCH New Chao Yu 1 participant 1 message Dec 30, 2022 F2FS file system

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/1 f2fs: fix error path of f2fs_create_flush_cmd_control()

If kthread_run() fails in f2fs_create_flush_cmd_control(), it should not release SM_I(sbi)->fcc_info, otherwise, w/ below testcase, it will cause NULL pointer dereference when accessing SM_I(sbi)->fcc_info in f2fs_issue_flush().

- mount -o noflush_merge /dev/vda /mnt/f2fs
- mount -o remount,flush_merge /dev/vda /mnt/f2fs -- kthread_run() fails
- dd if=/dev/zero of=/mnt/f2fs/file bs=4k count=1 conv=fsync

---
 fs/f2fs/segment.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/segment.c +1 -2
index 2646575f43de..7b18e8c02f5d 100644
@@ -663,8 +663,7 @@ int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi)
 	if (IS_ERR(fcc->f2fs_issue_flush)) {
 		int err = PTR_ERR(fcc->f2fs_issue_flush);
 
-		kfree(fcc);
-		SM_I(sbi)->fcc_info = NULL;
+		fcc->f2fs_issue_flush = NULL;
 		return err;
 	}
 
Signature · 1 line
2.36.1