summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Ming <mlin@kernel.org>2013-05-02 23:51:38 -0400
committerDavid Sterba <dsterba@suse.cz>2013-08-09 14:32:29 +0200
commit3d86ac20b74a736c4b7e0881dac5ff4d3dbbcd11 (patch)
tree4160930866900010970acdba7d6655c7cf3c4de4
parentde394eaed52692bbe3bc203528a40183dac1ddbc (diff)
btrfs-progs: pass up return value of walk_down_tree
Pass up return value of walk_down_tree, so the caller can handle it. This also fixes a segfault when read_tree_block fails with NULL returned. Signed-off-by: Lin Ming <mlin@kernel.org> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--cmds-check.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/cmds-check.c b/cmds-check.c
index d0344469..cc9606cd 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -1221,7 +1221,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
struct extent_buffer *next;
struct extent_buffer *cur;
u32 blocksize;
- int ret;
+ int ret, err = 0;
u64 refs;
WARN_ON(*level < 0);
@@ -1229,14 +1229,18 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
ret = btrfs_lookup_extent_info(NULL, root,
path->nodes[*level]->start,
*level, 1, &refs, NULL);
- if (ret < 0)
+ if (ret < 0) {
+ err = ret;
goto out;
+ }
if (refs > 1) {
ret = enter_shared_node(root, path->nodes[*level]->start,
refs, wc, *level);
- if (ret > 0)
+ if (ret > 0) {
+ err = ret;
goto out;
+ }
}
while (*level >= 0) {
@@ -1276,6 +1280,10 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
reada_walk_down(root, cur, path->slots[*level]);
next = read_tree_block(root, bytenr, blocksize,
ptr_gen);
+ if (!next) {
+ err = -EIO;
+ goto out;
+ }
}
*level = *level - 1;
@@ -1285,7 +1293,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
}
out:
path->slots[*level] = btrfs_header_nritems(path->nodes[*level]);
- return 0;
+ return err;
}
static int walk_up_tree(struct btrfs_root *root, struct btrfs_path *path,