From: David Sterba Date: Fri, 17 Feb 2017 18:42:43 +0000 (+0100) Subject: btrfs: do proper error handling in btrfs_insert_xattr_item X-Git-Tag: v4.14-rc1~1080^2~9^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9d04c607c21fafe0a346792d0d358e7ab9a768e;p=platform%2Fkernel%2Flinux-rpi3.git 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 Signed-off-by: David Sterba --- diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index b13d953..60a7506 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;