btrfs-progs: Fix memory leak in write_raid56_with_parity

Ebs and pointers are allocated, but if any of the allocation failed, we
should free the allocated memory.

Resolves-Coverity-CID: 1374101
Resolves-Coverity-CID: 1374100
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Qu Wenruo 2016-10-24 10:43:32 +08:00 committed by David Sterba
parent f529d6472e
commit 388cdce509
1 changed files with 4 additions and 1 deletions

View File

@ -2143,8 +2143,11 @@ int write_raid56_with_parity(struct btrfs_fs_info *info,
ebs = malloc(sizeof(*ebs) * multi->num_stripes);
pointers = malloc(sizeof(*pointers) * multi->num_stripes);
if (!ebs || !pointers)
if (!ebs || !pointers) {
free(ebs);
free(pointers);
return -ENOMEM;
}
if (stripe_len > alloc_size)
alloc_size = stripe_len;