Skip to content

Commit

Permalink
xattr handlers: plug a lock leak in simple_xattr_list
Browse files Browse the repository at this point in the history
The code could leak xattrs->lock on error.

Problem introduced with 786534b "tmpfs: listxattr should
include POSIX ACL xattrs".

Signed-off-by: Mateusz Guzik <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Mateusz Guzik authored and Al Viro committed Feb 20, 2016
1 parent 2feb55f commit 0e9a7da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
bool trusted = capable(CAP_SYS_ADMIN);
struct simple_xattr *xattr;
ssize_t remaining_size = size;
int err;
int err = 0;

#ifdef CONFIG_FS_POSIX_ACL
if (inode->i_acl) {
Expand All @@ -965,11 +965,11 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,

err = xattr_list_one(&buffer, &remaining_size, xattr->name);
if (err)
return err;
break;
}
spin_unlock(&xattrs->lock);

return size - remaining_size;
return err ? err : size - remaining_size;
}

/*
Expand Down

0 comments on commit 0e9a7da

Please sign in to comment.