From: Qiujun Huang <hqjagain@gmail.com>
To: tglx@linutronix.de, dan.carpenter@oracle.com, gregkh@linuxfoundation.org
Cc: viro@zeniv.linux.org.uk, deepa.kernel@gmail.com,
darrick.wong@oracle.com, linux-kernel@vger.kernel.org,
syzkaller-bugs@googlegroups.com, anenbupt@gmail.com,
Qiujun Huang <hqjagain@gmail.com>
Subject: [PATCH] minix: Fix NULL dereference in alloc_branch()
Date: Mon, 23 Mar 2020 20:57:00 +0800 [thread overview]
Message-ID: <20200323125700.7512-1-hqjagain@gmail.com> (raw)
Need to check the return value of sb_getblk.
Reported-by: syzbot+4a88b2b9dc280f47baf4@syzkaller.appspotmail.com
Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
fs/minix/itree_common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
index 043c3fdbc8e7..6edb0f11e8a0 100644
--- a/fs/minix/itree_common.c
+++ b/fs/minix/itree_common.c
@@ -85,6 +85,10 @@ static int alloc_branch(struct inode *inode,
break;
branch[n].key = cpu_to_block(nr);
bh = sb_getblk(inode->i_sb, parent);
+ if (!bh) {
+ minix_free_block(inode, block_to_cpu(branch[n].key));
+ break;
+ }
lock_buffer(bh);
memset(bh->b_data, 0, bh->b_size);
branch[n].bh = bh;
--
2.17.1
reply other threads:[~2020-03-23 12:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200323125700.7512-1-hqjagain@gmail.com \
--to=hqjagain@gmail.com \
--cc=anenbupt@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=darrick.wong@oracle.com \
--cc=deepa.kernel@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).