From: Bin Guo <guobin@linux.alibaba.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,
qemu-block@nongnu.org, qemu-stable@nongnu.org
Subject: [PATCH] hw/scsi/megasas: Abort in-flight commands before resetting frames
Date: Tue, 4 Aug 2026 14:18:05 +0800 [thread overview]
Message-ID: <20260804061805.39492-1-guobin@linux.alibaba.com> (raw)
megasas_init_firmware() called megasas_reset_frames() without first
aborting in-flight SCSI requests. This destroyed their scatter-gather
lists (setting the AddressSpace pointer to NULL) while the requests were
still active. A subsequent MFI_IDB abort would then dereference the NULL
AddressSpace in dma_aio_cancel().
Abort all commands before resetting frames, mirroring what
megasas_soft_reset() already does.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4092
Cc: qemu-stable@nongnu.org
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
---
hw/scsi/megasas.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 9e712721f8..e9758ddb90 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -641,6 +641,7 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd)
struct mfi_init_qinfo *initq = NULL;
uint32_t flags;
int ret = MFI_STAT_OK;
+ int i;
if (s->reply_queue_pa) {
trace_megasas_initq_mapped(s->reply_queue_pa);
@@ -684,6 +685,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd)
trace_megasas_init_queue((unsigned long)s->reply_queue_pa,
s->reply_queue_len, s->reply_queue_head,
s->reply_queue_tail, flags);
+ for (i = 0; i < s->fw_cmds; i++) {
+ megasas_abort_command(&s->frames[i]);
+ }
megasas_reset_frames(s);
s->fw_state = MFI_FWSTATE_OPERATIONAL;
out:
--
2.50.1 (Apple Git-155)
reply other threads:[~2026-08-04 6:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260804061805.39492-1-guobin@linux.alibaba.com \
--to=guobin@linux.alibaba.com \
--cc=fam@euphon.net \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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.