From: Tsutomu Itoh Date: Thu, 6 Oct 2011 04:37:08 +0000 (+0900) Subject: Btrfs: fix return value of btrfs_get_acl() X-Git-Tag: v2.6.39-400.9.0~845^2~42 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=6c701fe7f91d5f0dc723b46ff25e0edc70bb7a49;p=users%2Fjedix%2Flinux-maple.git Btrfs: fix return value of btrfs_get_acl() In btrfs_get_acl(), when the second __btrfs_getxattr() call fails, acl is not correctly set. Therefore, a wrong value might return to the caller. Signed-off-by: Tsutomu Itoh (cherry picked from commit cfbffc39ac89dbd5197cbeec2599a1128eb928f8) --- diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index b206d4c2720b..7fde7a583774 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c @@ -59,22 +59,19 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) 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)) { - kfree(value); - 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; }