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>
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);
if (ret > 0) {
path->slots[level]++;
continue;
- }
+ } else if (ret < 0)
+ return ret;
level = wc->level;
}
return 0;