mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hoi Pok Wu <wuhoipok@gmail.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: Hoi Pok Wu <wuhoipok@gmail.com>,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org,
	syzbot+035a381ea1afb63f098d@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: [PATCH] fs: f2fs: fix kernel discard_thread NULL dereference
Date: Mon, 17 Oct 2022 18:04:37 +0800	[thread overview]
Message-ID: <20221017100437.618363-1-wuhoipok@gmail.com> (raw)

Pointer discard_thread is pointing to nowhere, using IS_ERR prevents the
situation. IS_ERR also seen being used throughout the file.

Link: https://syzkaller.appspot.com/bug?id=9499bc6574cea5940e48199c2fd0732d9b11e5e1
Reported-by: syzbot+035a381ea1afb63f098d@syzkaller.appspotmail.com
Signed-off-by: Hoi Pok Wu <wuhoipok@gmail.com>
---
 fs/f2fs/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index acf3d3fa4363..79978b7206b5 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1634,7 +1634,8 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
 		struct task_struct *discard_thread = dcc->f2fs_issue_discard;
 
 		dcc->f2fs_issue_discard = NULL;
-		kthread_stop(discard_thread);
+		if (!IS_ERR(discard_thread))
+			kthread_stop(discard_thread);
 	}
 }
 
-- 
2.38.0


             reply	other threads:[~2022-10-17 10:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 10:04 Hoi Pok Wu [this message]
2022-10-17 12:23 ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221017100437.618363-1-wuhoipok@gmail.com \
    --to=wuhoipok@gmail.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+035a381ea1afb63f098d@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®