linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Cc: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Subject: [PATCH 1/5] btrfs-progs:free local variable buf upon unsuccessful returns
Date: Thu, 5 Sep 2013 10:38:54 +0800	[thread overview]
Message-ID: <1378348738-14451-2-git-send-email-guihc.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1378348738-14451-1-git-send-email-guihc.fnst@cn.fujitsu.com>

The variable "buf" passed into find_collision() as parameter "name" should be freed on unsuccessful returns.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
 btrfs-image.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/btrfs-image.c b/btrfs-image.c
index 3ea3730..1a52aa6 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -284,6 +284,7 @@ static char *find_collision(struct metadump_struct *md, char *name,
 	val = malloc(sizeof(struct name));
 	if (!val) {
 		fprintf(stderr, "Couldn't sanitize name, enomem\n");
+		free(name);
 		return NULL;
 	}
 
@@ -295,6 +296,7 @@ static char *find_collision(struct metadump_struct *md, char *name,
 	if (!val->sub) {
 		fprintf(stderr, "Couldn't sanitize name, enomem\n");
 		free(val);
+		free(name);
 		return NULL;
 	}
 
-- 
1.8.0.1


  reply	other threads:[~2013-09-05  2:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-05  2:38 [PATCH 0/5] Memory leaks amended Gui Hecheng
2013-09-05  2:38 ` Gui Hecheng [this message]
2013-09-05  2:38 ` [PATCH 2/5] btrfs-progs:local variable memory freed Gui Hecheng
2013-09-09 14:18   ` David Sterba
2013-09-09 14:22     ` David Sterba
2013-09-05  2:38 ` [PATCH 3/5] btrfs-progs: missing tree-freeing statements added Gui Hecheng
2013-09-05  2:38 ` [PATCH 4/5] btrfs-progs:free the local list pending_list in btrfs_scan_one_dir Gui Hecheng
2013-09-05  2:38 ` [PATCH 5/5] btrfs-progs:free strdup()s that are not freed Gui Hecheng
2013-09-05  7:00   ` Stefan Behrens
2013-09-05  7:10     ` Stefan Behrens
2013-09-05  8:08       ` Gui Hecheng
2013-09-05  8:10         ` Wang Shilong
2013-09-09 14:40       ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378348738-14451-2-git-send-email-guihc.fnst@cn.fujitsu.com \
    --to=guihc.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).