When we fail to read the block bitmap, we're returned an error pointer. It is incorrect to pass this to brelse, so save the error code and set the pointer to NULL before jumping out of the function. This avoids brelse()ing a nonpointer. Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- fs/ext4/mballoc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 19b8104..f185c97 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2906,6 +2906,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, bitmap_bh = ext4_read_block_bitmap(sb, ac->ac_b_ex.fe_group); if (IS_ERR(bitmap_bh)) { err = PTR_ERR(bitmap_bh); + bitmap_bh = NULL; goto out_err; } @@ -4774,6 +4775,7 @@ do_more: bitmap_bh = ext4_read_block_bitmap(sb, block_group); if (IS_ERR(bitmap_bh)) { err = PTR_ERR(bitmap_bh); + bitmap_bh = NULL; goto error_return; } gdp = ext4_get_group_desc(sb, block_group, &gd_bh); @@ -4944,6 +4946,7 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb, bitmap_bh = ext4_read_block_bitmap(sb, block_group); if (IS_ERR(bitmap_bh)) { err = PTR_ERR(bitmap_bh); + bitmap_bh = NULL; goto error_return; } -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html