mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 02:39:48 +00:00
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: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
parent
2f3014fc2a
commit
90d2c51dbb
1 changed files with 4 additions and 1 deletions
|
@ -5205,6 +5205,8 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
|
|||
next = btrfs_find_tree_block(root, bytenr, blocksize);
|
||||
if (!next) {
|
||||
next = btrfs_find_create_tree_block(root, bytenr, blocksize);
|
||||
if (!next)
|
||||
return -ENOMEM;
|
||||
reada = 1;
|
||||
}
|
||||
btrfs_tree_lock(next);
|
||||
|
@ -5417,7 +5419,8 @@ static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
|
|||
if (ret > 0) {
|
||||
path->slots[level]++;
|
||||
continue;
|
||||
}
|
||||
} else if (ret < 0)
|
||||
return ret;
|
||||
level = wc->level;
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue