Skip to content

Commit c6a6c96

Browse files
Dan Carpentertytso
authored andcommitted
ext4: fix error pointer dereference in ext4_mb_load_buddy_gfp()
This code calls folio_put() on an error pointer which will lead to a crash. Check for both error pointers and NULL pointers before calling folio_put(). Fixes: 5eea586 ("ext4: convert bd_buddy_page to bd_buddy_folio") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/eaafa1d9-a61c-4af4-9f97-d3ad72c60200@moroto.mountain Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 26770a7 commit c6a6c96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ext4/mballoc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group,
17171717
return 0;
17181718

17191719
err:
1720-
if (folio)
1720+
if (!IS_ERR_OR_NULL(folio))
17211721
folio_put(folio);
17221722
if (e4b->bd_bitmap_folio)
17231723
folio_put(e4b->bd_bitmap_folio);

0 commit comments

Comments
 (0)