Signed-off-by: Wenchao Xia <xiaw...@linux.vnet.ibm.com> --- block/qcow2-snapshot.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 40393b2..9e2d695 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -186,7 +186,7 @@ static int qcow2_write_snapshots(BlockDriverState *bs) } ret = bdrv_flush(bs); if (ret < 0) { - return ret; + goto fail; } /* The snapshot list position has not yet been updated, so these clusters @@ -194,7 +194,7 @@ static int qcow2_write_snapshots(BlockDriverState *bs) ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, offset, s->snapshots_size); if (ret < 0) { - return ret; + goto fail; } @@ -278,6 +278,9 @@ static int qcow2_write_snapshots(BlockDriverState *bs) return 0; fail: + /* free the new snapshot table */ + qcow2_free_clusters(bs, snapshots_offset, snapshots_size, + QCOW2_DISCARD_ALWAYS); return ret; } -- 1.7.1