Received: from eggs.gnu.org ([2001:4830:134:3::10]:56416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOqWH-0005pv-GV for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:56:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOqWC-0005Tp-Fw for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:56:49 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:39094 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOqWB-0005Qz-V2 for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:56:44 -0400 Date: Wed, 25 Sep 2013 16:56:40 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20130925145640.GB23504@irqsave.net> References: <1380119840-12672-1-git-send-email-mreitz@redhat.com> <1380119840-12672-4-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-4-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/3] qcow2: Always use error path in l2_allocate 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:20 (+0200), Max Reitz a =E9crit : > Just returning -errno in some cases prevents > trace_qcow2_l2_allocate_done from being executed (and, in one case, als= o > the unused allocated L2 table from being freed). Always going down the > error path fixes this. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-cluster.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) >=20 > diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c > index 1c3d3fc..c442f6c 100644 > --- a/block/qcow2-cluster.c > +++ b/block/qcow2-cluster.c > @@ -200,7 +200,8 @@ static int l2_allocate(BlockDriverState *bs, int l1= _index, uint64_t **table) > =20 > l2_offset =3D qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_= t)); > if (l2_offset < 0) { > - return l2_offset; > + ret =3D l2_offset; > + goto fail; > } > =20 > ret =3D qcow2_cache_flush(bs, s->refcount_block_cache); > @@ -213,7 +214,7 @@ static int l2_allocate(BlockDriverState *bs, int l1= _index, uint64_t **table) > trace_qcow2_l2_allocate_get_empty(bs, l1_index); > ret =3D qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (v= oid**) table); > if (ret < 0) { > - return ret; > + goto fail; > } > =20 > l2_table =3D *table; > --=20 > 1.8.3.1 >=20 >=20 Reviewed-by: Benoit Canet