btrfs-progs: handler memory allocation error in write_data_to_disk

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-07-28 02:16:43 +02:00
parent 02e22dbc1c
commit 96bc7f17df
1 changed files with 9 additions and 1 deletions

View File

@ -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); this_len = min(this_len, (u64)info->tree_root->nodesize);
eb = malloc(sizeof(struct extent_buffer) + this_len); 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); memset(eb, 0, sizeof(struct extent_buffer) + this_len);
eb->start = offset; eb->start = offset;
@ -823,6 +827,10 @@ int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset,
multi = NULL; multi = NULL;
} }
return 0; return 0;
out:
kfree(raid_map);
return ret;
} }
int set_extent_buffer_dirty(struct extent_buffer *eb) int set_extent_buffer_dirty(struct extent_buffer *eb)