aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-cluster.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2013-09-25 16:37:19 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2013-10-07 13:23:19 +0200
commite3b21ef9e016e6d91fd71e44af5e23fb359e18f9 (patch)
tree755ceabcf5a4b5e2c75cbf708099dd35d73e37e0 /block/qcow2-cluster.c
parentfda74f826baec78d685e5a87fd8a95bfb7bb2243 (diff)
downloadqemu-e3b21ef9e016e6d91fd71e44af5e23fb359e18f9.zip
qemu-e3b21ef9e016e6d91fd71e44af5e23fb359e18f9.tar.gz
qemu-e3b21ef9e016e6d91fd71e44af5e23fb359e18f9.tar.bz2
qcow2: Free allocated L2 cluster on error
If an error occurs in l2_allocate, the allocated (but unused) L2 cluster should be freed. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/qcow2-cluster.c')
-rw-r--r--block/qcow2-cluster.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 2ed45f0..0fd26bb 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -273,6 +273,10 @@ fail:
qcow2_cache_put(bs, s->l2_table_cache, (void**) table);
}
s->l1_table[l1_index] = old_l2_offset;
+ if (l2_offset > 0) {
+ qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t),
+ QCOW2_DISCARD_ALWAYS);
+ }
return ret;
}