Commit 90d2c51d authored by Miao Xie's avatar Miao Xie Committed by Chris Mason

Btrfs: add NULL check for do_walk_down()

btrfs_find_create_tree_block() may return NULL, so we must check the returned
value, or we will access a NULL pointer.
Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 2f3014fc
...@@ -5205,6 +5205,8 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, ...@@ -5205,6 +5205,8 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
next = btrfs_find_tree_block(root, bytenr, blocksize); next = btrfs_find_tree_block(root, bytenr, blocksize);
if (!next) { if (!next) {
next = btrfs_find_create_tree_block(root, bytenr, blocksize); next = btrfs_find_create_tree_block(root, bytenr, blocksize);
if (!next)
return -ENOMEM;
reada = 1; reada = 1;
} }
btrfs_tree_lock(next); btrfs_tree_lock(next);
...@@ -5417,7 +5419,8 @@ static noinline int walk_down_tree(struct btrfs_trans_handle *trans, ...@@ -5417,7 +5419,8 @@ static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
if (ret > 0) { if (ret > 0) {
path->slots[level]++; path->slots[level]++;
continue; continue;
} } else if (ret < 0)
return ret;
level = wc->level; level = wc->level;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment