Btrfs-progs: return immediately on tree search failure
authorFilipe David Borba Manana <fdmanana@gmail.com>
Mon, 29 Jul 2013 18:36:36 +0000 (19:36 +0100)
committerDavid Sterba <dsterba@suse.cz>
Tue, 3 Sep 2013 17:40:45 +0000 (19:40 +0200)
If the chunk tree search failed in volumes.c:btrfs_read_chunk_tree()
return immediately, rather than looping and use the invalid contents
of the path structure, causing weird errors/crash at run time.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
volumes.c

index 582f333..6182ed6 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -1717,6 +1717,8 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
        key.offset = 0;
        key.type = 0;
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
+       if (ret < 0)
+               goto error;
        while(1) {
                leaf = path->nodes[0];
                slot = path->slots[0];