From 96bc7f17df6e726eb1bb2716c06a748743924969 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 28 Jul 2016 02:16:43 +0200 Subject: btrfs-progs: handler memory allocation error in write_data_to_disk Signed-off-by: David Sterba --- extent_io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'extent_io.c') diff --git a/extent_io.c b/extent_io.c index c455b5a0..7b9eb8ef 100644 --- a/extent_io.c +++ b/extent_io.c @@ -772,7 +772,11 @@ int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset, this_len = min(this_len, (u64)info->tree_root->nodesize); eb = malloc(sizeof(struct extent_buffer) + this_len); - BUG_ON(!eb); + if (!eb) { + fprintf(stderr, "cannot allocate memory for eb\n"); + ret = -ENOMEM; + goto out; + } memset(eb, 0, sizeof(struct extent_buffer) + this_len); eb->start = offset; @@ -823,6 +827,10 @@ int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset, multi = NULL; } return 0; + +out: + kfree(raid_map); + return ret; } int set_extent_buffer_dirty(struct extent_buffer *eb) -- cgit v1.2.3