From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOqPz-0001gr-Rf for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:50:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOqPt-0003YU-01 for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:50:19 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:39083 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOqPs-0003YH-O3 for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:50:12 -0400 Date: Wed, 25 Sep 2013 16:50:10 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20130925145009.GA23504@irqsave.net> References: <1380119840-12672-1-git-send-email-mreitz@redhat.com> <1380119840-12672-3-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1380119840-12672-3-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/3] qcow2: Free allocated L2 cluster on error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi Le Wednesday 25 Sep 2013 =E0 16:37:19 (+0200), Max Reitz a =E9crit : > If an error occurs in l2_allocate, the allocated (but unused) L2 cluste= r > should be freed. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-cluster.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c > index f6d47c9..1c3d3fc 100644 > --- a/block/qcow2-cluster.c > +++ b/block/qcow2-cluster.c > @@ -269,6 +269,10 @@ fail: > qcow2_cache_put(bs, s->l2_table_cache, (void**) table); > } > s->l1_table[l1_index] =3D old_l2_offset; > + if (l2_offset > 0) { > + qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_= t), > + QCOW2_DISCARD_ALWAYS); > + } > return ret; > } > =20 > --=20 > 1.8.3.1 >=20 >=20 Reviewed-by: Benoit Canet