summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2016-10-24 10:43:32 +0800
committerDavid Sterba <dsterba@suse.com>2016-11-11 16:23:30 +0100
commit388cdce5092333efc569344908df9839a1c0cbba (patch)
treef87e98fa7710b4d51496335250af269d62e8e6c0
parentf529d6472e09066ab8a2fd8e730f1e8c2acf04d8 (diff)
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>
-rw-r--r--volumes.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/volumes.c b/volumes.c
index c128472d..e39f21ea 100644
--- a/volumes.c
+++ b/volumes.c
@@ -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;