Ebs and pointers are allocated, but if any of the allocation failed, we should free the allocated memory.
Reported-by: David Sterba <dste...@suse.cz> Resolves-Coverity-CID: 1296749 Signed-off-by: Qu Wenruo <quwen...@cn.fujitsu.com> --- volumes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/volumes.c b/volumes.c index a7abd92..f687b0d 100644 --- a/volumes.c +++ b/volumes.c @@ -2120,8 +2120,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; -- 2.10.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html