linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] btrfs/acl: adjust logical path of btrfs_get_acl()
@ 2010-07-29  8:26 Miao Xie
  0 siblings, 0 replies; only message in thread
From: Miao Xie @ 2010-07-29  8:26 UTC (permalink / raw)
  To: Chris Mason, Yan Zheng; +Cc: Linux Kernel, Linux Btrfs

From: Liu Bo <liubo2009@cn.fujitsu.com>

- There exists a memory leak.
- More checks of returned "size" are needed.

According to ext3_get_acl()'s style, we do some adjustments here.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/acl.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 1606dc1..2f4f65a 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -52,26 +52,25 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
 		BUG();
 	}
 
-	size = __btrfs_getxattr(inode, name, "", 0);
+	size = __btrfs_getxattr(inode, name, NULL, 0);
 	if (size > 0) {
 		value = kzalloc(size, GFP_NOFS);
 		if (!value)
 			return ERR_PTR(-ENOMEM);
 		size = __btrfs_getxattr(inode, name, value, size);
-		if (size > 0) {
-			acl = posix_acl_from_xattr(value, size);
-			if (IS_ERR(acl))
-				return acl;
-			set_cached_acl(inode, type, acl);
-		}
-		kfree(value);
+	}
+	if (size > 0) {
+		acl = posix_acl_from_xattr(value, size);
 	} else if (size == -ENOENT || size == -ENODATA || size == 0) {
 		/* FIXME, who returns -ENOENT?  I think nobody */
 		acl = NULL;
-		set_cached_acl(inode, type, acl);
 	} else {
 		acl = ERR_PTR(-EIO);
 	}
+	kfree(value);
+
+	if (!IS_ERR(acl))
+		set_cached_acl(inode, type, acl);
 
 	return acl;
 }
-- 
1.7.0.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-29  8:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-29  8:26 [PATCH 1/7] btrfs/acl: adjust logical path of btrfs_get_acl() Miao Xie

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