diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2016-10-24 10:43:32 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-11-11 16:23:30 +0100 |
commit | 388cdce5092333efc569344908df9839a1c0cbba (patch) | |
tree | f87e98fa7710b4d51496335250af269d62e8e6c0 /volumes.c | |
parent | f529d6472e09066ab8a2fd8e730f1e8c2acf04d8 (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>
Diffstat (limited to 'volumes.c')
-rw-r--r-- | volumes.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; |