From: Wang Shilong <wangshilong1991@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: wangsl-fnst@cn.fujitsu.com
Subject: [PATCH 2/2] Btrfs-progs: fix possible memory leak related to subvolume/snapshot creation
Date: Thu, 4 Jul 2013 00:07:38 +0800 [thread overview]
Message-ID: <1372867658-4144-2-git-send-email-wangshilong1991@gmail.com> (raw)
In-Reply-To: <1372867658-4144-1-git-send-email-wangshilong1991@gmail.com>
From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
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>
---
cmds-subvolume.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index ccb4762..9db989e 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);
--
1.7.11.7
next prev parent reply other threads:[~2013-07-03 16:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 16:07 [PATCH 1/2] Btrfs-progs: make pretty_sizes() works less error prone Wang Shilong
2013-07-03 16:07 ` Wang Shilong [this message]
2013-07-03 17:18 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372867658-4144-2-git-send-email-wangshilong1991@gmail.com \
--to=wangshilong1991@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wangsl-fnst@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).