btrfs-progs: catch memory allocation failure from alloc_data_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:
David Sterba 2016-01-06 15:52:11 +01:00
parent 62b4c169e4
commit 87296b5541

View File

@ -4413,6 +4413,9 @@ static struct data_backref *alloc_data_backref(struct extent_record *rec,
u64 max_size)
{
struct data_backref *ref = malloc(sizeof(*ref));
if (!ref)
return NULL;
memset(&ref->node, 0, sizeof(ref->node));
ref->node.is_data = 1;
@ -4725,9 +4728,11 @@ static int add_data_backref(struct cache_tree *extent_cache, u64 bytenr,
*/
back = find_data_backref(rec, parent, root, owner, offset, found_ref,
bytenr, max_size);
if (!back)
if (!back) {
back = alloc_data_backref(rec, parent, root, owner, offset,
max_size);
BUG_ON(!back);
}
if (found_ref) {
BUG_ON(num_refs != 1);