From 388cdce5092333efc569344908df9839a1c0cbba Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Mon, 24 Oct 2016 10:43:32 +0800 Subject: 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 Signed-off-by: David Sterba --- volumes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'volumes.c') 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; -- cgit v1.2.3