f2fs: fix error path of f2fs_create_flush_cmd_control()
Chao Yu
maintainerPATCH 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
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/segment.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/segment.c +1 -2
@@ -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