summaryrefslogtreecommitdiff
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorWang Shilong <wangsl-fnst@cn.fujitsu.com>2013-07-04 00:07:38 +0800
committerDavid Sterba <dsterba@suse.cz>2013-08-09 14:32:33 +0200
commit705e76ee8ddb2fd3d8127464b0c482b9fe43ef3e (patch)
tree4fd73807ae4e423a614feb30c2e22aabe73c007d /cmds-subvolume.c
parent876e3f9380d373ba76f9b6d4c08ff84327956abf (diff)
Btrfs-progs: fix possible memory leak related to subvolume/snapshot creation
The operation related qgroup inherit may fails, if it fails, we should free memory allocated,otherwise, memory leak happens. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index ccb47627..9db989eb 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -89,13 +89,17 @@ static int cmd_subvol_create(int argc, char **argv)
switch (c) {
case 'c':
res = qgroup_inherit_add_copy(&inherit, optarg, 0);
- if (res)
- return res;
+ if (res) {
+ retval = res;
+ goto out;
+ }
break;
case 'i':
res = qgroup_inherit_add_group(&inherit, optarg);
- if (res)
- return res;
+ if (res) {
+ retval = res;
+ goto out;
+ }
break;
default:
usage(cmd_subvol_create_usage);
@@ -516,21 +520,27 @@ static int cmd_snapshot(int argc, char **argv)
switch (c) {
case 'c':
res = qgroup_inherit_add_copy(&inherit, optarg, 0);
- if (res)
- return res;
+ if (res) {
+ retval = res;
+ goto out;
+ }
break;
case 'i':
res = qgroup_inherit_add_group(&inherit, optarg);
- if (res)
- return res;
+ if (res) {
+ retval = res;
+ goto out;
+ }
break;
case 'r':
readonly = 1;
break;
case 'x':
res = qgroup_inherit_add_copy(&inherit, optarg, 1);
- if (res)
- return res;
+ if (res) {
+ retval = res;
+ goto out;
+ }
break;
default:
usage(cmd_snapshot_usage);