summaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2015-02-23 22:50:49 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-10 18:39:20 +0300
commitb48138a2c718c91a10f8bd9d727722fb8b87e4b6 (patch)
treeda908f4d33ce4e19dff6f856f3268847ee46eda7 /fs/btrfs
parent52a25e71cc9c37007639f1a04a0c0d4e567f338a (diff)
downloadlinux-b48138a2c718c91a10f8bd9d727722fb8b87e4b6.tar.xz
Btrfs: do not ignore errors from btrfs_lookup_xattr in do_setxattr
[ Upstream commit 5cdf83edb8e41cad1ec8eab2d402b4f9d9eb7ee0 ] The return value from btrfs_lookup_xattr() can be a pointer encoding an error, therefore deal with it. This fixes commit 5f5bc6b1e2d5 ("Btrfs: make xattr replace operations atomic"). Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Chris Mason <clm@fb.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/xattr.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index fbb0533e977f..de5d69a63e3f 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -111,6 +111,8 @@ static int do_setxattr(struct btrfs_trans_handle *trans,
name, name_len, -1);
if (!di && (flags & XATTR_REPLACE))
ret = -ENODATA;
+ else if (IS_ERR(di))
+ ret = PTR_ERR(di);
else if (di)
ret = btrfs_delete_one_dir_name(trans, root, path, di);
goto out;
@@ -127,10 +129,12 @@ static int do_setxattr(struct btrfs_trans_handle *trans,
ASSERT(mutex_is_locked(&inode->i_mutex));
di = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode),
name, name_len, 0);
- if (!di) {
+ if (!di)
ret = -ENODATA;
+ else if (IS_ERR(di))
+ ret = PTR_ERR(di);
+ if (ret)
goto out;
- }
btrfs_release_path(path);
di = NULL;
}