From 62b4c169e448964c4918e29f0a65a8ac71a9c552 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_tree_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 bc594d57..8452fc65 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -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) { -- cgit v1.2.3