linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: Resolve memory-leak in btrfs qgroup show when quota disabled
@ 2017-09-26  9:28 Gu Jinxiang
  2017-09-26 11:27 ` David Sterba
  2017-09-28  6:20 ` Gu Jinxiang
  0 siblings, 2 replies; 4+ messages in thread
From: Gu Jinxiang @ 2017-09-26  9:28 UTC (permalink / raw)
  To: linux-btrfs

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




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

end of thread, other threads:[~2017-09-28  6:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-26  9:28 [PATCH] btrfs-progs: Resolve memory-leak in btrfs qgroup show when quota disabled Gu Jinxiang
2017-09-26 11:27 ` David Sterba
2017-09-28  6:24   ` Gu, Jinxiang
2017-09-28  6:20 ` Gu Jinxiang

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).