mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-16 17:56:51 +00:00
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>
This commit is contained in:
parent
876e3f9380
commit
705e76ee8d
@ -89,13 +89,17 @@ static int cmd_subvol_create(int argc, char **argv)
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
res = qgroup_inherit_add_copy(&inherit, optarg, 0);
|
res = qgroup_inherit_add_copy(&inherit, optarg, 0);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
retval = res;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
res = qgroup_inherit_add_group(&inherit, optarg);
|
res = qgroup_inherit_add_group(&inherit, optarg);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
retval = res;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(cmd_subvol_create_usage);
|
usage(cmd_subvol_create_usage);
|
||||||
@ -516,21 +520,27 @@ static int cmd_snapshot(int argc, char **argv)
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
res = qgroup_inherit_add_copy(&inherit, optarg, 0);
|
res = qgroup_inherit_add_copy(&inherit, optarg, 0);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
retval = res;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
res = qgroup_inherit_add_group(&inherit, optarg);
|
res = qgroup_inherit_add_group(&inherit, optarg);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
retval = res;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
readonly = 1;
|
readonly = 1;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
res = qgroup_inherit_add_copy(&inherit, optarg, 1);
|
res = qgroup_inherit_add_copy(&inherit, optarg, 1);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
retval = res;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(cmd_snapshot_usage);
|
usage(cmd_snapshot_usage);
|
||||||
|
Loading…
Reference in New Issue
Block a user