qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 02/20] scsi-generic: Remove bogus double complete
Date: Tue,  3 May 2011 18:50:14 +0200	[thread overview]
Message-ID: <1304441432-27434-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1304441432-27434-1-git-send-email-pbonzini@redhat.com>

scsi-generic scsi_read_complete() should not -both- call the client
complete callback with SCSI_REASON_DATA -and- call
scsi_command_complete().  The former will cause the client to queue a
new read or write request, while the later will free the request data
structure, thus causing the new read or write request to use a
freed/stale structure when it completes.

This patch fixes the bug, fixing a crash with scsi-generic & RHEL5.5
installer.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi-generic.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 9be1cca..102f1da 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -172,9 +172,11 @@ static void scsi_read_complete(void * opaque, int ret)
     DPRINTF("Data ready tag=0x%x len=%d\n", r->req.tag, len);
 
     r->len = -1;
-    r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len);
-    if (len == 0)
+    if (len == 0) {
         scsi_command_complete(r, 0);
+    } else {
+        r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len);
+    }
 }
 
 /* Read more data from scsi device into buffer.  */
-- 
1.7.4.4

  parent reply	other threads:[~2011-05-03 16:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-03 16:50 [Qemu-devel] [PATCH 00/20] SCSI subsystem improvements Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 01/20] scsi: add tracing of scsi requests Paolo Bonzini
2011-05-03 16:50 ` Paolo Bonzini [this message]
2011-05-03 16:50 ` [Qemu-devel] [PATCH 03/20] scsi: introduce scsi_req_data Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 04/20] scsi: introduce SCSIBusOps Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 05/20] scsi: reference-count requests Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 06/20] lsi: extract lsi_find_by_tag Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 07/20] scsi: Use 'SCSIRequest' directly Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 08/20] scsi: commonize purging requests Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 09/20] scsi: introduce scsi_req_abort Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 10/20] scsi: introduce scsi_req_cancel Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 11/20] scsi: use scsi_req_complete Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 12/20] scsi: Update sense code handling Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 13/20] scsi: do not call send_command directly Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 14/20] scsi: introduce scsi_req_new Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 15/20] scsi: introduce scsi_req_kick Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 16/20] scsi: introduce scsi_req_get_buf Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 17/20] scsi: Implement 'get_sense' callback Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 18/20] scsi-disk: add data direction checking Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 19/20] scsi: make write_data return void Paolo Bonzini
2011-05-03 16:50 ` [Qemu-devel] [PATCH 20/20] scsi-generic: Handle queue full Paolo Bonzini

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=1304441432-27434-3-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).