summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-01-06 15:52:11 +0100
committerDavid Sterba <dsterba@suse.com>2016-01-12 15:02:50 +0100
commit62b4c169e448964c4918e29f0a65a8ac71a9c552 (patch)
tree1ae4a7e934ae7fcb9f97336b6f1d676fd3c075c7
parentcb2b8b19c83ddb168b69307c4a68c2a2d39f2a5f (diff)
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>
-rw-r--r--cmds-check.c7
1 files changed, 6 insertions, 1 deletions
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) {