Btrfs: add error handling for extent buffer in print tree
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 15 Sep 2016 00:23:39 +0000 (17:23 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2016 16:04:01 +0000 (18:04 +0200)
Somehow we missed btrfs_print_tree when last time we
updated error handling for read_extent_block().

This keeps us from getting a NULL pointer panic when
btrfs_print_tree's read_extent_block() fails.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/print-tree.c

index 147dc6ca5de1f789cd0f9ef080303961b04f75d4..aaeee45d917df3bfdad371f9cd0850c016988fb7 100644 (file)
@@ -356,6 +356,13 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
                struct extent_buffer *next = read_tree_block(root,
                                        btrfs_node_blockptr(c, i),
                                        btrfs_node_ptr_generation(c, i));
+               if (IS_ERR(next)) {
+                       continue;
+               } else if (!extent_buffer_uptodate(next)) {
+                       free_extent_buffer(next);
+                       continue;
+               }
+
                if (btrfs_is_leaf(next) &&
                   level != 1)
                        BUG();