From: Gu JinXiang <gujx@xxxxxxxxxxxxxx>
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 | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 38382ea9..51d4f3a1 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) {
@@ -399,13 +398,21 @@ static int cmd_qgroup_show(int argc, char **argv)
qgroupid);
}
ret = btrfs_show_qgroups(fd, filter_set, comparer_set);
- if (ret == -ENOENT)
+ if (ret == -ENOENT) {
error("can't list qgroups: quotas not enabled");
- else if (ret < 0)
+ goto out;
+ } else if (ret < 0) {
error("can't list qgroups: %s", strerror(-ret));
+ goto out;
+ }
close_file_or_dir(fd, dirstream);
+ return !!ret;
+
out:
+ close_file_or_dir(fd, dirstream);
+ free(filter_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