Commit 5cdf83ed authored by Filipe Manana's avatar Filipe Manana Committed by Chris Mason

Btrfs: do not ignore errors from btrfs_lookup_xattr in do_setxattr

The return value from btrfs_lookup_xattr() can be a pointer encoding an
error, therefore deal with it. This fixes commit 5f5bc6b1
("Btrfs: make xattr replace operations atomic").
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 5dfe2be7
...@@ -111,6 +111,8 @@ static int do_setxattr(struct btrfs_trans_handle *trans, ...@@ -111,6 +111,8 @@ static int do_setxattr(struct btrfs_trans_handle *trans,
name, name_len, -1); name, name_len, -1);
if (!di && (flags & XATTR_REPLACE)) if (!di && (flags & XATTR_REPLACE))
ret = -ENODATA; ret = -ENODATA;
else if (IS_ERR(di))
ret = PTR_ERR(di);
else if (di) else if (di)
ret = btrfs_delete_one_dir_name(trans, root, path, di); ret = btrfs_delete_one_dir_name(trans, root, path, di);
goto out; goto out;
...@@ -127,10 +129,12 @@ static int do_setxattr(struct btrfs_trans_handle *trans, ...@@ -127,10 +129,12 @@ static int do_setxattr(struct btrfs_trans_handle *trans,
ASSERT(mutex_is_locked(&inode->i_mutex)); ASSERT(mutex_is_locked(&inode->i_mutex));
di = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode), di = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode),
name, name_len, 0); name, name_len, 0);
if (!di) { if (!di)
ret = -ENODATA; ret = -ENODATA;
else if (IS_ERR(di))
ret = PTR_ERR(di);
if (ret)
goto out; goto out;
}
btrfs_release_path(path); btrfs_release_path(path);
di = NULL; di = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment