diff options
author | David Sterba <dsterba@suse.com> | 2016-01-06 15:52:11 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-01-12 15:02:50 +0100 |
commit | 87296b5541313b4792f2a5fe0a30045d64f99a74 (patch) | |
tree | c75a3e80f307dd632a48372731e72d6eb0e94a29 /cmds-check.c | |
parent | 62b4c169e448964c4918e29f0a65a8ac71a9c552 (diff) |
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>
Diffstat (limited to 'cmds-check.c')
-rw-r--r-- | cmds-check.c | 7 |
1 files changed, 6 insertions, 1 deletions
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); |