All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 1/6] megasas: do not call pci_dma_unmap after having freed the frame once
Date: Mon, 28 Nov 2016 23:40:32 +0100	[thread overview]
Message-ID: <1480372837-109736-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1480372837-109736-1-git-send-email-pbonzini@redhat.com>

Commit 8cc4678 ("megasas: remove useless check for cmd->frame", 2016-07-17) was
wrong because I trusted Coverity too much.  It turns out that there _is_ a
path through which cmd->frame can become NULL.  After megasas_handle_frame's
switch (md->frame->header.frame_cmd), megasas_init_firmware can be called.
>From there, megasas_reset_frames will call megasas_unmap_frame which resets
cmd->frame = NULL.

However, there is another bug to fix in there, because megasas_unmap_frame
is called again after setting the command status.  In this case QEMU should
not do anything, instead it calls pci_dma_unmap again.  Harmless, but
better fix it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/megasas.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 52a4123..ca62952 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -461,9 +461,12 @@ static void megasas_unmap_frame(MegasasState *s, MegasasCmd *cmd)
 {
     PCIDevice *p = PCI_DEVICE(s);
 
-    pci_dma_unmap(p, cmd->frame, cmd->pa_size, 0, 0);
+    if (cmd->pa_size) {
+        pci_dma_unmap(p, cmd->frame, cmd->pa_size, 0, 0);
+    }
     cmd->frame = NULL;
     cmd->pa = 0;
+    cmd->pa_size = 0;
     clear_bit(cmd->index, s->frame_map);
 }
 
-- 
1.8.3.1

  reply	other threads:[~2016-11-28 22:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 22:40 [Qemu-devel] [PULL 0/6] More patches for QEMU 2.8-rc2 Paolo Bonzini
2016-11-28 22:40 ` Paolo Bonzini [this message]
2016-11-28 22:40 ` [Qemu-devel] [PULL 2/6] megasas: clean up and fix request completion/cancellation Paolo Bonzini
2016-11-28 22:40 ` [Qemu-devel] [PULL 3/6] pci-assign: sync MSI/MSI-X cap and table with PCIDevice Paolo Bonzini
2016-11-28 22:40 ` [Qemu-devel] [PULL 4/6] migration/pcspk: Add a property to state if pcspk is migrated Paolo Bonzini
2016-11-28 22:40 ` [Qemu-devel] [PULL 5/6] migration/pcspk: Turn migration of pcspk off for 2.7 and older Paolo Bonzini
2016-11-28 22:40 ` [Qemu-devel] [PULL 6/6] rules.mak: Use -r instead of -Wl, -r to fix building when PIE is default Paolo Bonzini
2016-11-29  9:56 ` [Qemu-devel] [PULL 0/6] More patches for QEMU 2.8-rc2 Stefan Hajnoczi
2016-11-29 10:05 ` Stefan Hajnoczi

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=1480372837-109736-2-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --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.