From: Gu Jinxiang <gujx@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] btrfs-progs: Resolve memory-leak in btrfs qgroup show when quota disabled
Date: Tue, 26 Sep 2017 17:28:31 +0800 [thread overview]
Message-ID: <1506418111-26620-1-git-send-email-gujx@cn.fujitsu.com> (raw)
When quota disabled, btrfs qgroup show exit with a error message,
but the allocated memory is not freed.
By the way, this bug marked as issue#20 in github.
Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
---
cmds-qgroup.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 38382ea9..5fbfaa17 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -369,9 +369,8 @@ static int cmd_qgroup_show(int argc, char **argv)
path = argv[optind];
fd = btrfs_open_dir(path, &dirstream, 1);
if (fd < 0) {
- free(filter_set);
- free(comparer_set);
- return 1;
+ ret = 1;
+ goto out;
}
if (sync) {
@@ -406,6 +405,10 @@ static int cmd_qgroup_show(int argc, char **argv)
close_file_or_dir(fd, dirstream);
out:
+ if (filter_set)
+ free(filter_set);
+ if (comparer_set)
+ free(comparer_set);
return !!ret;
}
--
2.14.1
next reply other threads:[~2017-09-26 9:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-26 9:28 Gu Jinxiang [this message]
2017-09-26 11:27 ` [PATCH] btrfs-progs: Resolve memory-leak in btrfs qgroup show when quota disabled David Sterba
2017-09-28 6:24 ` Gu, Jinxiang
2017-09-28 6:20 ` Gu Jinxiang
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=1506418111-26620-1-git-send-email-gujx@cn.fujitsu.com \
--to=gujx@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).