Skip to contentSkip to conversation

btrfs: fix memory leak on error path in btrfs_get_acl()

PATCH Superseded Mariusz Kozlowski 2 participants 4 messages Dec 15, 2010 – Dec 16, 2010 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix memory leak on error path in btrfs_get_acl()

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

---
 fs/btrfs/acl.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/btrfs/acl.c +1 -0
index 2222d16..11c9561 100644
@@ -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);
 		}
Signature · 1 line
1.7.0.4
#1 lore raw

On Wed, Dec 15, 2010 at 10:57 PM, Mariusz Kozlowski <[email protected]> w= rote:

fs/btrfs/acl.c static struct posix_acl *btrfs_get_acl(struct inode=

Quoted 12 lines

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

---
=A0fs/btrfs/acl.c | =A0 =A01 +
=A01 files changed, 1 insertions(+), 0 deletions(-)

fs/btrfs/acl.c +0 -0
index 2222d16..11c9561 100644
@@ -61,6 +61,7 @@ static struct posix_acl *btrfs_get_acl(struct inode=

*inode, int type)

Quoted 2 lines
fs/btrfs/acl.c +0 -0
 =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);

Quoted 2 lines

=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 { }

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return=

acl;

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_cached_acl(inode, =

type, acl);

Quoted 6 lines

=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

Quoted 4 lines

the body of a message to [email protected]
More majordomo info at =A0http://vger.kernel.org/majordomo-info.html Please read the FAQ at =A0http://www.tux.org/lkml/

#2 lore raw
Quoted 1 line · Miguel Ojeda

On Wed, Dec 15, 2010 at 10:57 PM, Mariusz Kozlowski <[email protected]>=

Quoted 7 lines · wrote:
Quoted 7 lines

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

---
=A0fs/btrfs/acl.c | =A0 =A01 +
=A01 files changed, 1 insertions(+), 0 deletions(-)

Quoted 5 lines

fs/btrfs/acl.c static struct posix_acl *btrfs_get_acl(struct ino=

Quoted 5 lines
fs/btrfs/acl.c +0 -0
index 2222d16..11c9561 100644
@@ -61,6 +61,7 @@ static struct posix_acl *btrfs_get_acl(struct ino=

de *inode, int type)

Quoted 2 lines
Quoted 2 lines
fs/btrfs/acl.c +0 -0
 =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);

Quoted 2 lines
Quoted 2 lines

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

Quoted 2 lines

=20
Be careful with the evil { }

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

Thanks.

Quoted 1 line
Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0retu=

rn acl;

Quoted 1 line
Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_cached_acl(inode=

, type, acl);

Quoted 6 lines
Quoted 6 lines

=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

Quoted 2 lines
Quoted 2 lines

the body of a message to [email protected]
More majordomo info at =A0http://vger.kernel.org/majordomo-info.htm=

l

Quoted 2 lines
Quoted 2 lines

Please read the FAQ at =A0http://www.tux.org/lkml/

--=20
Mariusz Kozlowski

#3 lore raw

PATCH v2 1/1 btrfs: fix memory leak on error path in btrfs_get_acl()

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

---
 fs/btrfs/acl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
fs/btrfs/acl.c +3 -1
index 2222d16..6d1410e 100644
@@ -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);
Signature · 1 line
1.7.0.4