From: Li Zefan <lizf@cn.fujitsu.com>
To: Yoshinori Sano <yoshinori.sano@gmail.com>
Cc: linux-btrfs@vger.kernel.org, chris.mason@oracle.com
Subject: Re: [PATCH] Btrfs: fix memory leaks in btrfs_new_inode()
Date: Mon, 11 Apr 2011 10:23:05 +0800 [thread overview]
Message-ID: <4DA26609.5060000@cn.fujitsu.com> (raw)
In-Reply-To: <1302316207-30806-1-git-send-email-yoshinori.sano@gmail.com>
Yoshinori Sano wrote:
> This patch fixes memory leaks in btrfs_new_inode().
>
> Signed-off-by: Yoshinori Sano <yoshinori.sano@gmail.com>
> ---
> fs/btrfs/inode.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index aa116dc..d8c93c1 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4536,14 +4536,17 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
> return ERR_PTR(-ENOMEM);
>
> inode = new_inode(root->fs_info->sb);
> - if (!inode)
> + if (!inode) {
> + btrfs_free_path(path);
> return ERR_PTR(-ENOMEM);
> + }
>
> if (dir) {
> trace_btrfs_inode_request(dir);
>
> ret = btrfs_set_inode_index(dir, index);
> if (ret) {
> + btrfs_free_path(path);
> iput(inode);
> return ERR_PTR(ret);
> }
It would be better to avoid multiple returns here:
fail_free_path:
btrfs_free_path(path);
fail_put_inode:
iput(inode);
fail:
...
prev parent reply other threads:[~2011-04-11 2:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-09 2:30 [PATCH] Btrfs: fix memory leaks in btrfs_new_inode() Yoshinori Sano
2011-04-11 2:23 ` Li Zefan [this message]
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=4DA26609.5060000@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=chris.mason@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=yoshinori.sano@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.