Skip to content

Commit

Permalink
btrfs: do proper error handling in btrfs_insert_xattr_item
Browse files Browse the repository at this point in the history
The space check in btrfs_insert_xattr_item is duplicated in it's caller
(do_setxattr) so we won't hit the BUG_ON. Continuing without any check
could be disasterous so turn it to a proper error handling.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
David Sterba committed Feb 28, 2017
1 parent fa25299 commit b9d04c6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/btrfs/dir-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
struct extent_buffer *leaf;
u32 data_size;

BUG_ON(name_len + data_len > BTRFS_MAX_XATTR_SIZE(root->fs_info));
if (name_len + data_len > BTRFS_MAX_XATTR_SIZE(root->fs_info))
return -ENOSPC;

key.objectid = objectid;
key.type = BTRFS_XATTR_ITEM_KEY;
Expand Down

0 comments on commit b9d04c6

Please sign in to comment.