From b91d84abc0df2195aaa06a79b565d8852b3099b2 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 23 Oct 2013 12:18:03 -0400 Subject: Btrfs-progs: just return -ENOENT if we don't find the root item We were bug_on(slot == 0), but that's just obnoxious, return -ENOENT so we can handle the situation properly. Thanks, Signed-off-by: Josef Bacik Signed-off-by: Chris Mason --- root-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'root-tree.c') diff --git a/root-tree.c b/root-tree.c index bdc85044..858fe2f5 100644 --- a/root-tree.c +++ b/root-tree.c @@ -40,10 +40,11 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0); if (ret < 0) goto out; + if (path->slots[0] == 0) + return -ENOENT; BUG_ON(ret == 0); l = path->nodes[0]; - BUG_ON(path->slots[0] == 0); slot = path->slots[0] - 1; btrfs_item_key_to_cpu(l, &found_key, slot); if (found_key.objectid != objectid) { -- cgit v1.2.3