btrfs-progs: convert: better error handling in ext2_read_used_space

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2017-01-30 16:58:57 +01:00
parent 5bcff79f14
commit 9368a77456
1 changed files with 5 additions and 2 deletions

View File

@ -136,8 +136,11 @@ static int ext2_read_used_space(struct btrfs_convert_context *cctx)
int ret = 0;
block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8;
/* Shouldn't happen */
BUG_ON(!fs->block_map);
if (!block_nbytes) {
error("EXT2_CLUSTERS_PER_GROUP too small: %llu",
(unsigned long long)(EXT2_CLUSTERS_PER_GROUP(fs->super)));
return -EINVAL;
}
block_bitmap = malloc(block_nbytes);
if (!block_bitmap)