Commit c6a6c969 authored by Dan Carpenter's avatar Dan Carpenter Committed by Theodore Ts'o

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: 5eea586b ("ext4: convert bd_buddy_page to bd_buddy_folio")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/eaafa1d9-a61c-4af4-9f97-d3ad72c60200@moroto.mountainSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 26770a71
...@@ -1717,7 +1717,7 @@ ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group, ...@@ -1717,7 +1717,7 @@ ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group,
return 0; return 0;
err: err:
if (folio) if (!IS_ERR_OR_NULL(folio))
folio_put(folio); folio_put(folio);
if (e4b->bd_bitmap_folio) if (e4b->bd_bitmap_folio)
folio_put(e4b->bd_bitmap_folio); folio_put(e4b->bd_bitmap_folio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment