summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2013-10-09 10:51:05 +0200
committerKevin Wolf <kwolf@redhat.com>2013-10-11 16:49:59 +0200
commit9186ad9658cc597937fbc03ad66bceb3a0515d99 (patch)
tree1fea3eb6f04ddb311afa3108ad0dfb3a333c5340 /block
parent37d41f0a04e5017d37906728a806d7944e867a2a (diff)
downloadqemu-9186ad9658cc597937fbc03ad66bceb3a0515d99.tar.gz
qemu-9186ad9658cc597937fbc03ad66bceb3a0515d99.tar.bz2
qemu-9186ad9658cc597937fbc03ad66bceb3a0515d99.zip
qcow2: Free allocated snapshot table on error
If an error occurs during qcow2_write_snapshots, the newly allocated snapshot table clusters are leaked and should thus be freed. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qcow2-snapshot.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 33379749c1..f6f3e6423d 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -279,6 +279,10 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
return 0;
fail:
+ if (snapshots_offset > 0) {
+ qcow2_free_clusters(bs, snapshots_offset, snapshots_size,
+ QCOW2_DISCARD_ALWAYS);
+ }
return ret;
}