aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-07-28 02:16:43 +0200
committerDavid Sterba <dsterba@suse.com>2016-07-28 14:08:30 +0200
commit96bc7f17df6e726eb1bb2716c06a748743924969 (patch)
treeb243a5dd17ed5b142121f3de78b2f76669e644f2
parent02e22dbc1c76f46ad0916a4e843577fe9cd0f645 (diff)
downloadbtrfs-progs-96bc7f17df6e726eb1bb2716c06a748743924969.tar.gz
btrfs-progs-96bc7f17df6e726eb1bb2716c06a748743924969.tar.xz
btrfs-progs-96bc7f17df6e726eb1bb2716c06a748743924969.zip
btrfs-progs: handler memory allocation error in write_data_to_disk
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--extent_io.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/extent_io.c b/extent_io.c
index c455b5a..7b9eb8e 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)