aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Guzik <mguzik@redhat.com>2016-02-03 20:56:30 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-02-20 00:15:51 -0500
commit0e9a7da51b028aee7a72c95096c99fe5ea2a01f0 (patch)
tree9ea3ec020202ebc2c38f581f410f201abad7db28
parent2feb55f89096b22e2de066e411a3263647211987 (diff)
xattr handlers: plug a lock leak in simple_xattr_list
The code could leak xattrs->lock on error. Problem introduced with 786534b92f3ce68f4 "tmpfs: listxattr should include POSIX ACL xattrs". Signed-off-by: Mateusz Guzik <mguzik@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/xattr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/xattr.c b/fs/xattr.c
index 07d0e47f6a7f..4861322e28e8 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -940,7 +940,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
940 bool trusted = capable(CAP_SYS_ADMIN); 940 bool trusted = capable(CAP_SYS_ADMIN);
941 struct simple_xattr *xattr; 941 struct simple_xattr *xattr;
942 ssize_t remaining_size = size; 942 ssize_t remaining_size = size;
943 int err; 943 int err = 0;
944 944
945#ifdef CONFIG_FS_POSIX_ACL 945#ifdef CONFIG_FS_POSIX_ACL
946 if (inode->i_acl) { 946 if (inode->i_acl) {
@@ -965,11 +965,11 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
965 965
966 err = xattr_list_one(&buffer, &remaining_size, xattr->name); 966 err = xattr_list_one(&buffer, &remaining_size, xattr->name);
967 if (err) 967 if (err)
968 return err; 968 break;
969 } 969 }
970 spin_unlock(&xattrs->lock); 970 spin_unlock(&xattrs->lock);
971 971
972 return size - remaining_size; 972 return err ? err : size - remaining_size;
973} 973}
974 974
975/* 975/*