linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix memory leak on error path in btrfs_get_acl()
@ 2010-12-15 21:57 Mariusz Kozlowski
  2010-12-15 22:49 ` Miguel Ojeda
  0 siblings, 1 reply; 4+ messages in thread
From: Mariusz Kozlowski @ 2010-12-15 21:57 UTC (permalink / raw)
  To: Chris Mason; +Cc: linux-btrfs, linux-kernel, Mariusz Kozlowski

If posix_acl_from_xattr() fails we leak memory stored in 'value'.

Signed-off-by: Mariusz Kozlowski <mk@lab.zgora.pl>
---
 fs/btrfs/acl.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 2222d16..11c9561 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -61,6 +61,7 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
 		if (size > 0) {
 			acl = posix_acl_from_xattr(value, size);
 			if (IS_ERR(acl))
+				kfree(value);
 				return acl;
 			set_cached_acl(inode, type, acl);
 		}
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: fix memory leak on error path in btrfs_get_acl()
  2010-12-15 21:57 [PATCH] btrfs: fix memory leak on error path in btrfs_get_acl() Mariusz Kozlowski
@ 2010-12-15 22:49 ` Miguel Ojeda
  2010-12-16  5:56   ` Mariusz Kozlowski
  0 siblings, 1 reply; 4+ messages in thread
From: Miguel Ojeda @ 2010-12-15 22:49 UTC (permalink / raw)
  To: Mariusz Kozlowski; +Cc: Chris Mason, linux-btrfs, linux-kernel

On Wed, Dec 15, 2010 at 10:57 PM, Mariusz Kozlowski <mk@lab.zgora.pl> w=
rote:
> If posix_acl_from_xattr() fails we leak memory stored in 'value'.
>
> Signed-off-by: Mariusz Kozlowski <mk@lab.zgora.pl>
> ---
> =A0fs/btrfs/acl.c | =A0 =A01 +
> =A01 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
> index 2222d16..11c9561 100644
> --- a/fs/btrfs/acl.c
> +++ b/fs/btrfs/acl.c
> @@ -61,6 +61,7 @@ static struct posix_acl *btrfs_get_acl(struct inode=
 *inode, int type)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (size > 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0acl =3D posix_acl_from=
_xattr(value, size);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (IS_ERR(acl))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 kfree(v=
alue);

Be careful with the evil { }

> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return=
 acl;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_cached_acl(inode, =
type, acl);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kerne=
l" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at =A0http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at =A0http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: fix memory leak on error path in btrfs_get_acl()
  2010-12-15 22:49 ` Miguel Ojeda
@ 2010-12-16  5:56   ` Mariusz Kozlowski
  2010-12-16  6:10     ` [PATCH v2] " Mariusz Kozlowski
  0 siblings, 1 reply; 4+ messages in thread
From: Mariusz Kozlowski @ 2010-12-16  5:56 UTC (permalink / raw)
  To: Miguel Ojeda; +Cc: Mariusz Kozlowski, Chris Mason, linux-btrfs, linux-kernel

On Wed, Dec 15, 2010 at 11:49:39PM +0100, Miguel Ojeda wrote:
> On Wed, Dec 15, 2010 at 10:57 PM, Mariusz Kozlowski <mk@lab.zgora.pl>=
 wrote:
> > If posix_acl_from_xattr() fails we leak memory stored in 'value'.
> >
> > Signed-off-by: Mariusz Kozlowski <mk@lab.zgora.pl>
> > ---
> > =A0fs/btrfs/acl.c | =A0 =A01 +
> > =A01 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
> > index 2222d16..11c9561 100644
> > --- a/fs/btrfs/acl.c
> > +++ b/fs/btrfs/acl.c
> > @@ -61,6 +61,7 @@ static struct posix_acl *btrfs_get_acl(struct ino=
de *inode, int type)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (size > 0) {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0acl =3D posix_acl_fr=
om_xattr(value, size);
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (IS_ERR(acl))
> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 kfree=
(value);
>=20
> Be careful with the evil { }

Dang. Too much python recently i guess. Will send v2 shortly.

Thanks.

> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0retu=
rn acl;
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_cached_acl(inode=
, type, acl);
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> > --
> > 1.7.0.4
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-ker=
nel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at =A0http://vger.kernel.org/majordomo-info.htm=
l
> > Please read the FAQ at =A0http://www.tux.org/lkml/
> >

--=20
Mariusz Kozlowski

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] btrfs: fix memory leak on error path in btrfs_get_acl()
  2010-12-16  5:56   ` Mariusz Kozlowski
@ 2010-12-16  6:10     ` Mariusz Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Mariusz Kozlowski @ 2010-12-16  6:10 UTC (permalink / raw)
  To: Chris Mason; +Cc: Miguel Ojeda, linux-btrfs, linux-kernel, Mariusz Kozlowski

If posix_acl_from_xattr() fails we leak memory stored in 'value'.

Signed-off-by: Mariusz Kozlowski <mk@lab.zgora.pl>
---
 fs/btrfs/acl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

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);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-16  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-15 21:57 [PATCH] btrfs: fix memory leak on error path in btrfs_get_acl() Mariusz Kozlowski
2010-12-15 22:49 ` Miguel Ojeda
2010-12-16  5:56   ` Mariusz Kozlowski
2010-12-16  6:10     ` [PATCH v2] " Mariusz Kozlowski

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).