Re: KASAN: null-ptr-deref Write in get_block
From: Qiujun Huang
Date: Sun Mar 22 2020 - 08:07:09 EST
Need to check the return value of sb_getblk.
Signed-off-by: Qiujun Huang <hqjagain@xxxxxxxxx>
---
fs/minix/itree_common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
index 043c3fd..eedd79f 100644
--- a/fs/minix/itree_common.c
+++ b/fs/minix/itree_common.c
@@ -85,6 +85,8 @@ static int alloc_branch(struct inode *inode,
break;
branch[n].key = cpu_to_block(nr);
bh = sb_getblk(inode->i_sb, parent);
+ if (!bh)
+ break;
lock_buffer(bh);
memset(bh->b_data, 0, bh->b_size);
branch[n].bh = bh;
--