linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K. V" <aneesh.kumar@linux.vnet.ibm.com>
To: Jesper Juhl <jj@chaosbits.net>, linux-btrfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Chris Mason <chris.mason@oracle.com>
Subject: Re: [PATCH] btrfs: Mem leak in btrfs_get_acl()
Date: Fri, 07 Jan 2011 14:52:10 +0530	[thread overview]
Message-ID: <87vd21kr0d.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1101062242320.13988@swampdragon.chaosbits.net>

On Thu, 6 Jan 2011 22:45:21 +0100 (CET), Jesper Juhl <jj@chaosbits.net> wrote:
> 
> It seems to me that we leak the memory allocated to 'value' in 
> btrfs_get_acl() if the call to posix_acl_from_xattr() fails.
> Here's a patch that attempts to correct that problem.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

I posted a similar patch long time back.  But never got picked up

http://article.gmane.org/gmane.comp.file-systems.btrfs/6164

Message-id:"1279547924-25141-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com"

> ---
>  acl.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
>   compile tested only.
> 
> diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
> index 2222d16..6d1410e 100644
> --- a/fs/btrfs/acl.c
> +++ b/fs/btrfs/acl.c
> @@ -60,8 +60,10 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
>  		size = __btrfs_getxattr(inode, name, value, size);
>  		if (size > 0) {
>  			acl = posix_acl_from_xattr(value, size);
> -			if (IS_ERR(acl))
> +			if (IS_ERR(acl)) {
> +				kfree(value);
>  				return acl;
> +			}
>  			set_cached_acl(inode, type, acl);
>  		}
>  		kfree(value);
> 
> 


-aneesh

  reply	other threads:[~2011-01-07  9:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-06 21:45 [PATCH] btrfs: Mem leak in btrfs_get_acl() Jesper Juhl
2011-01-07  9:22 ` Aneesh Kumar K. V [this message]
2011-01-08 20:26   ` Jesper Juhl

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=87vd21kr0d.fsf@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=chris.mason@oracle.com \
    --cc=jj@chaosbits.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).