* [PATCH] btrfs: Mem leak in btrfs_get_acl()
@ 2011-01-06 21:45 Jesper Juhl
2011-01-07 9:22 ` Aneesh Kumar K. V
0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2011-01-06 21:45 UTC (permalink / raw)
To: linux-btrfs; +Cc: linux-kernel, Chris Mason
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>
---
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);
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Mem leak in btrfs_get_acl()
2011-01-06 21:45 [PATCH] btrfs: Mem leak in btrfs_get_acl() Jesper Juhl
@ 2011-01-07 9:22 ` Aneesh Kumar K. V
2011-01-08 20:26 ` Jesper Juhl
0 siblings, 1 reply; 3+ messages in thread
From: Aneesh Kumar K. V @ 2011-01-07 9:22 UTC (permalink / raw)
To: Jesper Juhl, linux-btrfs; +Cc: linux-kernel, Chris Mason
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Mem leak in btrfs_get_acl()
2011-01-07 9:22 ` Aneesh Kumar K. V
@ 2011-01-08 20:26 ` Jesper Juhl
0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2011-01-08 20:26 UTC (permalink / raw)
To: Aneesh Kumar K. V; +Cc: linux-btrfs, linux-kernel, Chris Mason
On Fri, 7 Jan 2011, Aneesh Kumar K. V wrote:
> 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"
>
I see. Was not aware of that.
Ok, since they are identical and yours was posted first, yours should be
the one merged (if any) I think.
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-08 20:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-06 21:45 [PATCH] btrfs: Mem leak in btrfs_get_acl() Jesper Juhl
2011-01-07 9:22 ` Aneesh Kumar K. V
2011-01-08 20:26 ` Jesper Juhl
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).