summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-08-31 20:38:46 +0200
committerDavid Sterba <dsterba@suse.com>2016-09-21 14:12:38 +0200
commit1ef93ea8632b89598d7723a04a2d268b70333168 (patch)
tree48e911e91131e2023534ae8dbd652d245a039f15
parentb318553f33dc59b6afdc7d264dcfbfe835ccc3d4 (diff)
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>
-rw-r--r--ctree.c4
-rw-r--r--disk-io.c6
-rw-r--r--extent-tree.c3
-rw-r--r--file-item.c7
-rw-r--r--inode-map.c4
-rw-r--r--root-tree.c10
-rw-r--r--volumes.c3
7 files changed, 27 insertions, 10 deletions
diff --git a/ctree.c b/ctree.c
index a98ad185..d07ec7d9 100644
--- a/ctree.c
+++ b/ctree.c
@@ -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];
diff --git a/disk-io.c b/disk-io.c
index 2fd3330f..b7202fab 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -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)
diff --git a/extent-tree.c b/extent-tree.c
index 0607be66..fb627940 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -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);
diff --git a/file-item.c b/file-item.c
index 7a3bbf35..55d2d475 100644
--- a/file-item.c
+++ b/file-item.c
@@ -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;
diff --git a/inode-map.c b/inode-map.c
index 9e4dcd3c..9000e69b 100644
--- a/inode-map.c
+++ b/inode-map.c
@@ -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);
diff --git a/root-tree.c b/root-tree.c
index 934d02ef..cca424e3 100644
--- a/root-tree.c
+++ b/root-tree.c
@@ -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;
diff --git a/volumes.c b/volumes.c
index 2d07e66a..e022c16e 100644
--- a/volumes.c
+++ b/volumes.c
@@ -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;