@@ -548,13 +548,20 @@ static void mb_group_bb_bitmap_alloc(struct super_block *sb,
struct buffer_head *bh;
grp->bb_bitmap = kmalloc(sb->s_blocksize, GFP_NOFS);
- BUG_ON(grp->bb_bitmap == NULL);
+ if (!grp->bb_bitmap)
+ goto out;
bh = ext4_read_block_bitmap(sb, group);
- BUG_ON(IS_ERR_OR_NULL(bh));
+ if (IS_ERR_OR_NULL(bh)) {
+ kfree(grp->bb_bitmap);
+ grp->bb_bitmap = NULL;
+ goto out;
+ }
memcpy(grp->bb_bitmap, bh->b_data, sb->s_blocksize);
put_bh(bh);
+out:
+ return;
}
static void mb_group_bb_bitmap_free(struct ext4_group_info *grp)
Remove the BUG_ON() logic if kmalloc() or ext4_read_block_bitmap() fails. We should simply mark grp->bb_bitmap as NULL if above happens. In fact ext4_read_block_bitmap() may even return an error in case of resize ioctl. Hence remove this BUG_ON logic (fstests ext4/032 may trigger this). --- Should we add a ext4_msg() if any of above fails? Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com> --- fs/ext4/mballoc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)