[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240105193331.1180331-1-xzou017@ucr.edu>
Date: Fri, 5 Jan 2024 11:33:31 -0800
From: Xiaochen Zou <xzou017@....edu>
To: aivazian.tigran@...il.com
Cc: linux-kernel@...r.kernel.org,
Xiaochen Zou <xzou017@....edu>
Subject: [PATCH] fs/bfs: Null check to prevent null-ptr-deref bug
Similar to ea2b62f3058 (fs/sysv: Null check to prevent
null-ptr-deref bug), bfs is lack of return value check for
sb_getblk(). Adding a null check to prevent null-ptr-defer bug
Signed-off-by: Xiaochen Zou <xzou017@....edu>
---
fs/bfs/file.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index adc2230079c6..35688424bde3 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -39,6 +39,8 @@ static int bfs_move_block(unsigned long from, unsigned long to,
if (!bh)
return -EIO;
new = sb_getblk(sb, to);
+ if (unlikely(!new))
+ return -ENOMEM;
memcpy(new->b_data, bh->b_data, bh->b_size);
mark_buffer_dirty(new);
bforget(bh);
--
2.25.1
Powered by blists - more mailing lists