From patchwork Tue Jun 19 06:02:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 165653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 88EECB6FFD for ; Tue, 19 Jun 2012 16:03:00 +1000 (EST) Received: from localhost ([::1]:42471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgrWk-0004VP-1Y for incoming@patchwork.ozlabs.org; Tue, 19 Jun 2012 02:02:58 -0400 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 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id q5J62dOg024302; Tue, 19 Jun 2012 01:02:41 -0500 Message-ID: <1340085758.28143.4.camel@pasglop> From: Benjamin Herrenschmidt To: "qemu-devel@nongnu.org" Date: Tue, 19 Jun 2012 16:02:38 +1000 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 63.228.1.57 Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Alexander Graf Subject: [Qemu-devel] [PATCH] spapr_vscsi: Error handling fixes 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 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));