From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTpUH-0007Wd-4g for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:51:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTpUA-0001sY-UH for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:51:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTpUA-0001sQ-MQ for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:51:14 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r998pDZg022079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Oct 2013 04:51:13 -0400 From: Max Reitz Date: Wed, 9 Oct 2013 10:51:05 +0200 Message-Id: <1381308666-24268-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1381308666-24268-1-git-send-email-mreitz@redhat.com> References: <1381308666-24268-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] qcow2: Free allocated snapshot table on error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz 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 --- block/qcow2-snapshot.c | 4 ++++ 1 file changed, 4 insertions(+) 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; } -- 1.8.3.1