From 412d4f1fe3a14c7e61efbd0ad4280323de71606a Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 7 Dec 2011 15:54:13 -0500 Subject: [PATCH 32/35] Btrfs-progs: don't bug out if we can't find the last root Return an error instead of BUG()'ing out. Signed-off-by: Josef Bacik --- root-tree.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/root-tree.c b/root-tree.c index 782472c..7a6ae0a 100644 --- a/root-tree.c +++ b/root-tree.c @@ -43,6 +43,11 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, BUG_ON(ret == 0); l = path->nodes[0]; + if (path->slots[0] == 0) { + ret = -ENOENT; + goto out; + } + BUG_ON(path->slots[0] == 0); slot = path->slots[0] - 1; btrfs_item_key_to_cpu(l, &found_key, slot); -- 1.7.6.233.gd79bc