From 1ef93ea8632b89598d7723a04a2d268b70333168 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 31 Aug 2016 20:38:46 +0200 Subject: 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 --- root-tree.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'root-tree.c') 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; -- cgit v1.2.3