From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUeIJ-00070w-O2 for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:06:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUeID-0005FI-Oz for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:06:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUeID-0005E5-HR for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:06:17 -0400 From: Kevin Wolf Date: Fri, 11 Oct 2013 17:05:04 +0200 Message-Id: <1381503951-27985-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1381503951-27985-1-git-send-email-kwolf@redhat.com> References: <1381503951-27985-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 14/61] qcow2: Free allocated snapshot table on error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: 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 Signed-off-by: Kevin Wolf --- 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.1.4