All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
	Alexander Graf <agraf@suse.de>
Subject: [PATCH] spapr_vscsi: Error handling fixes
Date: Tue, 19 Jun 2012 16:02:38 +1000	[thread overview]
Message-ID: <1340085758.28143.4.camel@pasglop> (raw)

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 <benh@kernel.crashing.org>
---
 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));
 

WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org,
	Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [PATCH] spapr_vscsi: Error handling fixes
Date: Tue, 19 Jun 2012 16:02:38 +1000	[thread overview]
Message-ID: <1340085758.28143.4.camel@pasglop> (raw)

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 <benh@kernel.crashing.org>
---
 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));
 

WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
	Alexander Graf <agraf@suse.de>
Subject: [PATCH] spapr_vscsi: Error handling fixes
Date: Tue, 19 Jun 2012 06:02:38 +0000	[thread overview]
Message-ID: <1340085758.28143.4.camel@pasglop> (raw)

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 <benh@kernel.crashing.org>
---
 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));
 



             reply	other threads:[~2012-06-19  6:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19  6:02 Benjamin Herrenschmidt [this message]
2012-06-19  6:02 ` [PATCH] spapr_vscsi: Error handling fixes Benjamin Herrenschmidt
2012-06-19  6:02 ` [Qemu-devel] " Benjamin Herrenschmidt
2012-06-19 11:31 ` Andreas Färber
2012-06-19 11:31   ` Andreas Färber
2012-06-19 11:31   ` Andreas Färber
2012-06-19 20:18   ` Benjamin Herrenschmidt
2012-06-19 20:18     ` [Qemu-devel] " Benjamin Herrenschmidt
2012-06-19 20:18     ` Benjamin Herrenschmidt
2012-06-19 20:20     ` Alexander Graf
2012-06-19 20:20       ` Alexander Graf
2012-06-19 20:20       ` Alexander Graf
2012-06-19 20:46       ` Benjamin Herrenschmidt
2012-06-19 20:46         ` Benjamin Herrenschmidt
2012-06-19 20:46         ` Benjamin Herrenschmidt
2012-06-19 20:57 ` Alexander Graf
2012-06-19 20:57   ` Alexander Graf
2012-06-19 20:57   ` [Qemu-devel] " Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340085758.28143.4.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.