From: Byongho Lee <bhlee.kernel@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/3] btrfs-progs: fix memory leak in btrfs-map-logical main()
Date: Fri, 28 Aug 2015 00:38:17 +0900 [thread overview]
Message-ID: <1440689898-35178-3-git-send-email-bhlee.kernel@gmail.com> (raw)
In-Reply-To: <1440689898-35178-1-git-send-email-bhlee.kernel@gmail.com>
In btrfs-map-logical main(), strdup() allocates memory to output_file,
but that memory is not freed.
So add missing free() calls before return.
Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
---
btrfs-map-logical.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index a88e56e39dbb..d9fa6b29d3c9 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -262,6 +262,7 @@ int main(int ac, char **av)
root = open_ctree(dev, 0, 0);
if (!root) {
fprintf(stderr, "Open ctree failed\n");
+ free(output_file);
exit(1);
}
@@ -354,6 +355,7 @@ out_close_fd:
if (output_file && out_fd != 1)
close(out_fd);
close:
+ free(output_file);
close_ctree(root);
if (ret < 0)
ret = 1;
--
2.5.0
next prev parent reply other threads:[~2015-08-27 15:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 15:38 [PATCH 0/3] btrfs-progs: Small fixes for code using strdup() Byongho Lee
2015-08-27 15:38 ` [PATCH 1/3] btrfs-progs: fix memory leak in btrfs-convert main() Byongho Lee
2015-08-31 15:06 ` David Sterba
2015-08-27 15:38 ` Byongho Lee [this message]
2015-08-28 17:26 ` [PATCH 2/3] btrfs-progs: fix memory leak in btrfs-map-logical main() David Sterba
2015-08-27 15:38 ` [PATCH 3/3] btrfs-progs: add memory allocation fail check in btrfs_add_to_fsid() Byongho Lee
2015-08-28 17:28 ` 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=1440689898-35178-3-git-send-email-bhlee.kernel@gmail.com \
--to=bhlee.kernel@gmail.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).