[PATCH] f2fs: fix to invalidate dcc->f2fs_issue_discard in error path

From: Chao Yu
Date: Thu Oct 13 2022 - 11:57:06 EST


Otherwise, latter f2fs_stop_discard_thread() may access invalid
dcc->f2fs_issue_discard.

Signed-off-by: Chao Yu <chao@xxxxxxxxxx>
---
fs/f2fs/segment.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 460048f3c850..cf5f534aa887 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2026,8 +2026,10 @@ int f2fs_start_discard_thread(struct f2fs_sb_info *sbi)

dcc->f2fs_issue_discard = kthread_run(issue_discard_thread, sbi,
"f2fs_discard-%u:%u", MAJOR(dev), MINOR(dev));
- if (IS_ERR(dcc->f2fs_issue_discard))
+ if (IS_ERR(dcc->f2fs_issue_discard)) {
err = PTR_ERR(dcc->f2fs_issue_discard);
+ dcc->f2fs_issue_discard = NULL;
+ }

return err;
}
--
2.25.1