Fix possible pointer dereference
PATCH 1/1 Fix possible pointer dereference
We should always check btrfs_alloc_path(). Some places BUG(), others return -ENOMEM, btrfs_insert_dir_item() seems like it can return safely.
Signed-off-by Diego Calleja <[email protected]>
fs/btrfs/dir-item.c renamed from fs/btrfs/dir-item.c.BAK +3 -0
@@ -147,6 +147,9 @@ int btrfs_insert_dir_item(struct btrfs_t key.offset =btrfs_name_hash (name, name_len); path =btrfs_alloc_path (); +if (!path) +return -ENOMEM ; + path->leave_spinning =1 ; data_size =sizeof (*dir_item) + name_len;
Quoted 3 lines · Diego Calleja
We should always check
btrfs_alloc_path(). Some placesBUG(), others return-ENOMEM,btrfs_insert_dir_item()seems like it can return safely.
The problem is that all the callers don't handle errors.
It doesn't make sense to fix it low-level currently when it cannot be handled properly higher up anyways.
Proper out of memory handling needs much more work, one liners don't really help.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.