mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-08 13:47:07 +00:00
btrfs-progs: catch memory allocation failure from alloc_tree_backref
Do the dumb BUG_ON now, the function needs more changes to handle all errors. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
cb2b8b19c8
commit
62b4c169e4
@ -4354,6 +4354,9 @@ static struct tree_backref *alloc_tree_backref(struct extent_record *rec,
|
||||
u64 parent, u64 root)
|
||||
{
|
||||
struct tree_backref *ref = malloc(sizeof(*ref));
|
||||
|
||||
if (!ref)
|
||||
return NULL;
|
||||
memset(&ref->node, 0, sizeof(ref->node));
|
||||
if (parent > 0) {
|
||||
ref->parent = parent;
|
||||
@ -4660,8 +4663,10 @@ static int add_tree_backref(struct cache_tree *extent_cache, u64 bytenr,
|
||||
}
|
||||
|
||||
back = find_tree_backref(rec, parent, root);
|
||||
if (!back)
|
||||
if (!back) {
|
||||
back = alloc_tree_backref(rec, parent, root);
|
||||
BUG_ON(!back);
|
||||
}
|
||||
|
||||
if (found_ref) {
|
||||
if (back->node.found_ref) {
|
||||
|
Loading…
Reference in New Issue
Block a user