From patchwork Mon Oct 7 11:28:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 281079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 102352C0094 for ; Mon, 7 Oct 2013 22:32:43 +1100 (EST) Received: from localhost ([::1]:58804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT93I-0001Nw-Tl for incoming@patchwork.ozlabs.org; Mon, 07 Oct 2013 07:32:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT8ze-0004AX-Ve for qemu-devel@nongnu.org; Mon, 07 Oct 2013 07:28:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VT8zZ-0003KJ-V6 for qemu-devel@nongnu.org; Mon, 07 Oct 2013 07:28:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT8zZ-0003KE-Ht for qemu-devel@nongnu.org; Mon, 07 Oct 2013 07:28:49 -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 r97BSm0U030646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Oct 2013 07:28:48 -0400 Received: from localhost (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r97BSkd8027651; Mon, 7 Oct 2013 07:28:47 -0400 From: Stefan Hajnoczi To: Date: Mon, 7 Oct 2013 13:28:07 +0200 Message-Id: <1381145289-6591-7-git-send-email-stefanha@redhat.com> In-Reply-To: <1381145289-6591-1-git-send-email-stefanha@redhat.com> References: <1381145289-6591-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , Anthony Liguori , Max Reitz Subject: [Qemu-devel] [PULL 6/8] qcow2: Free allocated L2 cluster on error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Max Reitz If an error occurs in l2_allocate, the allocated (but unused) L2 cluster should be freed. Signed-off-by: Max Reitz Reviewed-by: Benoit Canet Signed-off-by: Stefan Hajnoczi --- block/qcow2-cluster.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 2ed45f0..0fd26bb 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -273,6 +273,10 @@ fail: qcow2_cache_put(bs, s->l2_table_cache, (void**) table); } s->l1_table[l1_index] = old_l2_offset; + if (l2_offset > 0) { + qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t), + QCOW2_DISCARD_ALWAYS); + } return ret; }