linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] btrfs-progs: Fix memory leak in write_raid56_with_parity
@ 2016-10-24  2:43 Qu Wenruo
  2016-10-24  2:43 ` [PATCH 2/4] btrfs-progs: fsck: Fix patch allocation check and leak in check_fs_first_inode Qu Wenruo
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Qu Wenruo @ 2016-10-24  2:43 UTC (permalink / raw)
  To: linux-btrfs, dsterba

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

Reported-by: David Sterba <dsterba@suse.cz>
Resolves-Coverity-CID: 1296749
Signed-off-by: Qu Wenruo <quwenruo@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




^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-25 14:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-24  2:43 [PATCH 1/4] btrfs-progs: Fix memory leak in write_raid56_with_parity Qu Wenruo
2016-10-24  2:43 ` [PATCH 2/4] btrfs-progs: fsck: Fix patch allocation check and leak in check_fs_first_inode Qu Wenruo
2016-10-24  2:43 ` [PATCH 3/4] btrfs-progs: utils: Fix NULL pointer derefernces in string_is_numerical Qu Wenruo
2016-10-24  2:43 ` [PATCH 4/4] btrfs-progs: fsck: Fix NULL pointer dereference for possible memory allocation failure Qu Wenruo
2016-10-24  3:04 ` [PATCH 1/4] btrfs-progs: Fix memory leak in write_raid56_with_parity Qu Wenruo
2016-10-25 14:35 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).