From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Date: Tue, 19 Jun 2012 11:31:57 +0000 Subject: Re: [Qemu-devel] [PATCH] spapr_vscsi: Error handling fixes Message-Id: <4FE0632D.5080505@suse.de> List-Id: References: <1340085758.28143.4.camel@pasglop> In-Reply-To: <1340085758.28143.4.camel@pasglop> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: Benjamin Herrenschmidt Cc: "qemu-devel@nongnu.org" , kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Alexander Graf Am 19.06.2012 08:02, schrieb Benjamin Herrenschmidt: > We were incorrectly g_free'ing an object that isn't allocated > in one error path and failed to release it completely in another > > This fixes qemu crashes with some cases of IO errors. > > Signed-off-by: Benjamin Herrenschmidt > --- > hw/spapr_vscsi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c > index d2fe3e5..6afc3b4 100644 > --- a/hw/spapr_vscsi.c > +++ b/hw/spapr_vscsi.c > @@ -801,6 +801,7 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_crq *crq) > if (crq->s.IU_length > sizeof(union viosrp_iu)) { > fprintf(stderr, "VSCSI: SRP IU too long (%d bytes) !\n", > crq->s.IU_length); > + vscsi_put_req(req); > return; > } > > @@ -808,7 +809,8 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_crq *crq) > if (spapr_vio_dma_read(&s->vdev, crq->s.IU_data_ptr, &req->iu, > crq->s.IU_length)) { > fprintf(stderr, "vscsi_got_payload: DMA read failure !\n"); > - g_free(req); > + vscsi_put_req(req); > + return; Tab alert. :) /-F > } > memcpy(&req->crq, crq, sizeof(vscsi_crq)); > > > > -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Subject: Re: [Qemu-devel] [PATCH] spapr_vscsi: Error handling fixes Date: Tue, 19 Jun 2012 13:31:57 +0200 Message-ID: <4FE0632D.5080505@suse.de> References: <1340085758.28143.4.camel@pasglop> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: "qemu-devel@nongnu.org" , kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Alexander Graf To: Benjamin Herrenschmidt Return-path: In-Reply-To: <1340085758.28143.4.camel@pasglop> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Am 19.06.2012 08:02, schrieb Benjamin Herrenschmidt: > We were incorrectly g_free'ing an object that isn't allocated > in one error path and failed to release it completely in another >=20 > This fixes qemu crashes with some cases of IO errors. >=20 > Signed-off-by: Benjamin Herrenschmidt > --- > hw/spapr_vscsi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c > index d2fe3e5..6afc3b4 100644 > --- a/hw/spapr_vscsi.c > +++ b/hw/spapr_vscsi.c > @@ -801,6 +801,7 @@ static void vscsi_got_payload(VSCSIState *s, vscs= i_crq *crq) > if (crq->s.IU_length > sizeof(union viosrp_iu)) { > fprintf(stderr, "VSCSI: SRP IU too long (%d bytes) !\n", > crq->s.IU_length); > + vscsi_put_req(req); > return; > } > =20 > @@ -808,7 +809,8 @@ static void vscsi_got_payload(VSCSIState *s, vscs= i_crq *crq) > if (spapr_vio_dma_read(&s->vdev, crq->s.IU_data_ptr, &req->iu, > crq->s.IU_length)) { > fprintf(stderr, "vscsi_got_payload: DMA read failure !\n"); > - g_free(req); > + vscsi_put_req(req); > + return; Tab alert. :) /-F > } > memcpy(&req->crq, crq, sizeof(vscsi_crq)); > =20 >=20 >=20 >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3= =BCrnberg From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgwfP-0000it-Pa for qemu-devel@nongnu.org; Tue, 19 Jun 2012 07:32:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgwfF-0007f5-Rw for qemu-devel@nongnu.org; Tue, 19 Jun 2012 07:32:15 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45358 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgwfF-0007ei-LU for qemu-devel@nongnu.org; Tue, 19 Jun 2012 07:32:05 -0400 Message-ID: <4FE0632D.5080505@suse.de> Date: Tue, 19 Jun 2012 13:31:57 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1340085758.28143.4.camel@pasglop> In-Reply-To: <1340085758.28143.4.camel@pasglop> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] spapr_vscsi: Error handling fixes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Benjamin Herrenschmidt Cc: kvm-ppc@vger.kernel.org, "qemu-devel@nongnu.org" , kvm@vger.kernel.org, Alexander Graf Am 19.06.2012 08:02, schrieb Benjamin Herrenschmidt: > We were incorrectly g_free'ing an object that isn't allocated > in one error path and failed to release it completely in another >=20 > This fixes qemu crashes with some cases of IO errors. >=20 > Signed-off-by: Benjamin Herrenschmidt > --- > hw/spapr_vscsi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c > index d2fe3e5..6afc3b4 100644 > --- a/hw/spapr_vscsi.c > +++ b/hw/spapr_vscsi.c > @@ -801,6 +801,7 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_= crq *crq) > if (crq->s.IU_length > sizeof(union viosrp_iu)) { > fprintf(stderr, "VSCSI: SRP IU too long (%d bytes) !\n", > crq->s.IU_length); > + vscsi_put_req(req); > return; > } > =20 > @@ -808,7 +809,8 @@ static void vscsi_got_payload(VSCSIState *s, vscsi_= crq *crq) > if (spapr_vio_dma_read(&s->vdev, crq->s.IU_data_ptr, &req->iu, > crq->s.IU_length)) { > fprintf(stderr, "vscsi_got_payload: DMA read failure !\n"); > - g_free(req); > + vscsi_put_req(req); > + return; Tab alert. :) /-F > } > memcpy(&req->crq, crq, sizeof(vscsi_crq)); > =20 >=20 >=20 >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg