From 87296b5541313b4792f2a5fe0a30045d64f99a74 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 6 Jan 2016 15:52:11 +0100 Subject: 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 --- cmds-check.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmds-check.c') diff --git a/cmds-check.c b/cmds-check.c index 8452fc65..266451a8 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -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); -- cgit v1.2.3