Skip to content

Commit b9d04c6

Browse files
committed
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 <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent fa25299 commit b9d04c6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/dir-item.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
8080
struct extent_buffer *leaf;
8181
u32 data_size;
8282

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

8586
key.objectid = objectid;
8687
key.type = BTRFS_XATTR_ITEM_KEY;

0 commit comments

Comments
 (0)