Skip to contentSkip to conversation

spapr_vscsi: Error handling fixes

PATCH Applied Benjamin Herrenschmidt 3 participants 6 messages Jun 19, 2012 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spapr_vscsi: Error handling fixes

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.

---
 hw/spapr_vscsi.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/spapr_vscsi.c +3 -1
index d2fe3e5..6afc3b4 100644
@@ -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));
 
#1 lore raw

Am 19.06.2012 08:02, schrieb Benjamin Herrenschmidt:

Quoted 23 lines

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.

---
 hw/spapr_vscsi.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/spapr_vscsi.c +1 -0
index d2fe3e5..6afc3b4 100644
@@ -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;
     }
 

hw/spapr_vscsi.c static void vscsi_got_payload(VSCSIState *s, vscsi_crq *crq) · line 814

Quoted 7 lines
hw/spapr_vscsi.c +2 -1
@@ -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

Quoted 6 lines
hw/spapr_vscsi.c +0 -0
     }
     memcpy(&req->crq, crq, sizeof(vscsi_crq));
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#2 lore raw
Quoted 1 line · Andreas Färber

Tab alert. :)

Argh :-) Gotta get an emacs config for use with qemu :-)

Cheers,
Ben.

#3 lore raw
Quoted 4 lines · Benjamin Herrenschmidt
Quoted 1 line · Andreas Färber

Tab alert. :)

Argh :-) Gotta get an emacs config for use with qemu :-)

So do you want to resend? I can just fix it on the fly too.

Alex

#4 lore raw
Quoted 1 line · Alexander Graf

So do you want to resend? I can just fix it on the fly too.

If you can then sure, please do :-)

Cheers,
Ben.