Received: from eggs.gnu.org ([208.118.235.92]:39336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcuYJ-0002Mc-MA for qemu-devel@nongnu.org; Thu, 16 May 2013 05:32:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcuYF-0002Df-6E for qemu-devel@nongnu.org; Thu, 16 May 2013 05:32:47 -0400 Received: from mail-bk0-x230.google.com ([2a00:1450:4008:c01::230]:49025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcuYF-0002DZ-0k for qemu-devel@nongnu.org; Thu, 16 May 2013 05:32:43 -0400 Received: by mail-bk0-f48.google.com with SMTP id jf3so1535875bkc.21 for ; Thu, 16 May 2013 02:32:42 -0700 (PDT) Date: Thu, 16 May 2013 11:32:39 +0200 From: Stefan Hajnoczi Message-ID: <20130516093239.GB8853@stefanha-thinkpad.redhat.com> References: <1368607419-15178-1-git-send-email-xiawenc@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1368607419-15178-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org On Wed, May 15, 2013 at 04:43:38PM +0800, Wenchao Xia wrote: > Signed-off-by: Wenchao Xia > --- > 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.