diff mbox series

[RFC,12/20] ext4: mballoc: Fix possible NULL ptr dereference from mb_cmp_bitmaps()

Message ID d6a1398e719c864993213c899325c3a703eeeb77.1588313626.git.riteshh@linux.ibm.com
State Superseded
Headers show
Series ext4: Fix ENOSPC error, improve mballoc dbg, other cleanups | expand

Commit Message

Ritesh Harjani May 1, 2020, 6:29 a.m. UTC
Make sure to check for e4b->bd_info->bb_bitmap == NULL, in
mb_cmp_bitmaps() and return if NULL, to avoid possible NULL ptr
dereference. Similar to how we do this in other ifdef DOUBLE_CHECK

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
 fs/ext4/mballoc.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series


diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 5e59c18c89c0..e32f3675f962 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -522,6 +522,8 @@  static void mb_mark_used_double(struct ext4_buddy *e4b, int first, int count)
 static void mb_cmp_bitmaps(struct ext4_buddy *e4b, void *bitmap)
+	if (unlikely(e4b->bd_info->bb_bitmap == NULL))
+		return;
 	if (memcmp(e4b->bd_info->bb_bitmap, bitmap, e4b->bd_sb->s_blocksize)) {
 		unsigned char *b1, *b2;
 		int i;