aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-cache.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-08-22 16:12:51 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-08-22 16:12:51 +0100
commit33886ebeec0c0ff6253a49253fae0db44c9ed0f3 (patch)
tree1e666965b66772c0d5e64beb98a7585c08936fd8 /block/qcow2-cache.c
parent43fe62757b0b90af448e02c9bd55b62960556360 (diff)
parentbd39e6ed0b88a1473c652c97e731a156cccf16e2 (diff)
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block patches # gpg: Signature made Fri 22 Aug 2014 14:47:53 BST using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (29 commits) qemu-img: Allow cache mode specification for amend qemu-img: Allow source cache mode specification vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted blkdebug: Delete BH in bdrv_aio_cancel qemu-iotests: add test case 101 for short file I/O raw-posix: fix O_DIRECT short reads block/iscsi: fix memory corruption on iscsi resize block/vvfat.c: remove debugging code to reinit stderr if NULL iotests: Add test for image filename construction quorum: Implement bdrv_refresh_filename() nbd: Implement bdrv_refresh_filename() blkverify: Implement bdrv_refresh_filename() blkdebug: Implement bdrv_refresh_filename() block: Add bdrv_refresh_filename() virtio-blk: fix reference a pointer which might be freed virtio-blk: allow block_resize with dataplane block: acquire AioContext in qmp_block_resize() qemu-iotests: Fix 028 reference output for qed test-coroutine: test cost introduced by coroutine iotests: Add test for qcow2's cache options ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block/qcow2-cache.c')
-rw-r--r--block/qcow2-cache.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index 5353b44828..904f6b1f44 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -48,9 +48,12 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables)
Qcow2Cache *c;
int i;
- c = g_malloc0(sizeof(*c));
+ c = g_new0(Qcow2Cache, 1);
c->size = num_tables;
- c->entries = g_malloc0(sizeof(*c->entries) * num_tables);
+ c->entries = g_try_new0(Qcow2CachedTable, num_tables);
+ if (!c->entries) {
+ goto fail;
+ }
for (i = 0; i < c->size; i++) {
c->entries[i].table = qemu_try_blockalign(bs->file, s->cluster_size);
@@ -62,8 +65,10 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables)
return c;
fail:
- for (i = 0; i < c->size; i++) {
- qemu_vfree(c->entries[i].table);
+ if (c->entries) {
+ for (i = 0; i < c->size; i++) {
+ qemu_vfree(c->entries[i].table);
+ }
}
g_free(c->entries);
g_free(c);