linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] minix: Fix NULL dereference in alloc_branch()
@ 2020-03-23 12:57 Qiujun Huang
  0 siblings, 0 replies; only message in thread
From: Qiujun Huang @ 2020-03-23 12:57 UTC (permalink / raw)
  To: tglx, dan.carpenter, gregkh
  Cc: viro, deepa.kernel, darrick.wong, linux-kernel, syzkaller-bugs,
	anenbupt, Qiujun Huang

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-23 12:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 12:57 [PATCH] minix: Fix NULL dereference in alloc_branch() Qiujun Huang

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).