From: Max Reitz Date: Wed, 9 Oct 2013 08:51:05 +0000 (+0200) Subject: qcow2: Free allocated snapshot table on error X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~1297^2~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9186ad9658cc597937fbc03ad66bceb3a0515d99;p=sdk%2Femulator%2Fqemu.git 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 Signed-off-by: Kevin Wolf --- diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 3337974..f6f3e64 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; }