btrfs-progs: handle errors from btrfs_alloc_path

All functions already return an error condition, so the callers should
expect that.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-08-31 20:38:46 +02:00
parent b318553f33
commit 1ef93ea863
7 changed files with 27 additions and 10 deletions

View File

@ -2580,7 +2580,9 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
unsigned long ptr;
path = btrfs_alloc_path();
BUG_ON(!path);
if (!path)
return -ENOMEM;
ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
if (!ret) {
leaf = path->nodes[0];

View File

@ -739,7 +739,11 @@ struct btrfs_root *btrfs_read_fs_root_no_cache(struct btrfs_fs_info *fs_info,
root, fs_info, location->objectid);
path = btrfs_alloc_path();
BUG_ON(!path);
if (!path) {
free(root);
return ERR_PTR(-ENOMEM);
}
ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0);
if (ret != 0) {
if (ret > 0)

View File

@ -2714,7 +2714,8 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
size += sizeof(*block_info);
path = btrfs_alloc_path();
BUG_ON(!path);
if (!path)
return -ENOMEM;
ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
ins, size);

View File

@ -42,7 +42,9 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
struct extent_buffer *leaf;
path = btrfs_alloc_path();
BUG_ON(!path);
if (!path)
return -ENOMEM;
file_key.objectid = objectid;
file_key.offset = pos;
btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
@ -188,7 +190,8 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
btrfs_super_csum_size(root->fs_info->super_copy);
path = btrfs_alloc_path();
BUG_ON(!path);
if (!path)
return -ENOMEM;
file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
file_key.offset = bytenr;

View File

@ -39,7 +39,9 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
u64 search_start = dirid;
path = btrfs_alloc_path();
BUG_ON(!path);
if (!path)
return -ENOMEM;
search_start = root->last_inode_alloc;
search_start = max((unsigned long long)search_start,
BTRFS_FIRST_FREE_OBJECTID);

View File

@ -31,12 +31,14 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
int ret;
int slot;
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
search_key.objectid = objectid;
search_key.type = BTRFS_ROOT_ITEM_KEY;
search_key.offset = (u64)-1;
path = btrfs_alloc_path();
BUG_ON(!path);
ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
if (ret < 0)
goto out;
@ -74,7 +76,9 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
u32 old_len;
path = btrfs_alloc_path();
BUG_ON(!path);
if (!path)
return -ENOMEM;
ret = btrfs_search_slot(trans, root, key, path, 0, 1);
if (ret < 0)
goto out;

View File

@ -459,7 +459,8 @@ static int find_next_chunk(struct btrfs_root *root, u64 objectid, u64 *offset)
struct btrfs_key found_key;
path = btrfs_alloc_path();
BUG_ON(!path);
if (!path)
return -ENOMEM;
key.objectid = objectid;
key.offset = (u64)-1;