diff options
author | David Sterba <dsterba@suse.com> | 2017-02-17 19:42:43 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-02-28 14:27:11 +0100 |
commit | b9d04c607c21fafe0a346792d0d358e7ab9a768e (patch) | |
tree | 1f6ab876f9759503b17c6e1fa97af8c38938251e /fs | |
parent | fa2529923d3bc5f0b39ff7a7c52be74c4aea6f2a (diff) | |
download | linux-b9d04c607c21fafe0a346792d0d358e7ab9a768e.tar.bz2 |
btrfs: do proper error handling in btrfs_insert_xattr_item
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/dir-item.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index b13d9536d4de..60a750678a82 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c @@ -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; |