On Wed, May 15, 2013 at 04:43:38PM +0800, Wenchao Xia wrote: > Signed-off-by: Wenchao Xia <xiaw...@linux.vnet.ibm.com> > --- > block/qcow2-snapshot.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c > index 992a5c8..a6065a9 100644 > --- a/block/qcow2-snapshot.c > +++ b/block/qcow2-snapshot.c > @@ -268,6 +268,8 @@ static int qcow2_write_snapshots(BlockDriverState *bs) > return 0; > > fail: > + /* free the new snapshot table */ > + qcow2_free_clusters(bs, snapshots_offset, snapshots_size); > return ret; > }
snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); offset = snapshots_offset; if (offset < 0) { return offset; } ret = bdrv_flush(bs); if (ret < 0) { return ret; } For completeness the bdrv_flush() return ret should be change to a goto fail so that we cover all failure cases.