[PATCH] btrfs-progs: Resolve memory-leak in btrfs qgroup show when quota disabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux