From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgrWd-0004VJ-K6 for qemu-devel@nongnu.org; Tue, 19 Jun 2012 02:02:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgrWY-0005eE-Jp for qemu-devel@nongnu.org; Tue, 19 Jun 2012 02:02:51 -0400 Received: from gate.crashing.org ([63.228.1.57]:47189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgrWY-0005e7-BW for qemu-devel@nongnu.org; Tue, 19 Jun 2012 02:02:46 -0400 Message-ID: <1340085758.28143.4.camel@pasglop> From: Benjamin Herrenschmidt Date: Tue, 19 Jun 2012 16:02:38 +1000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Subject: [Qemu-devel] [PATCH] spapr_vscsi: Error handling fixes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Alexander Graf 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; } memcpy(&req->crq, crq, sizeof(vscsi_crq));