[PATCH] scsi: mptfusion: Handle firmware events one at a time again
From: Praneeth Balasubramanian
Date: Fri Dec 04 2026 - 13:49:35 EST
mptsas handles firmware events, such as device hot plug and expander
status changes, as work items on ioc->fw_event_q. The SAS topology code
relies on these handlers running one at a time. For example,
mptsas_hotplug_work() looks up an expander's port_info with
mptsas_find_portinfo_by_handle() without sas_topology_mutex, although
the comment above that function says the mutex must be held, and then
passes it to mptsas_expander_refresh(). mptsas_expander_delete(), run
for an expander "not responding" event, unlinks and frees the same
port_info, also without the mutex.
The queue used to be single threaded. Commit b2990536f447 ("scsi: mpt:
Remove deprecated create_singlethread_workqueue") made it an unordered
workqueue, reasoning that only a single work item is queued on it. But
mptsas queues a separate work item for every firmware event. Since that
change, two events can be handled at the same time, and a hot plug event
can use a port_info that an expander removal event has just freed.
Use an ordered workqueue again, so firmware events are handled one at a
time as the topology code expects. An ordered workqueue is unbound, so
WQ_PERCPU is dropped.
The unlocked lookup was found by a static check that turns the locking
rule in a function's comment into a Clang context-analysis requirement
on its callers.
Fixes: b2990536f447 ("scsi: mpt: Remove deprecated create_singlethread_workqueue")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Praneeth Balasubramanian <praneethb2002@xxxxxxxxx>
---
Notes:
This was found by a compiler-based check, part of research at UCSB SecLab.
The locking rule stated in the kernel-doc comment of the called function
was turned into a Clang context-analysis requirement (__must_hold) on that
function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every
caller. An LLM was used only to turn the comment into a machine-readable
rule; the report itself comes from the compiler. The patch and changelog
were drafted with Claude Opus 5.5. I reviewed the patch and take
responsibility for it.
Testing: builds without new warnings with W=1 (x86_64, clang 23,
allmodconfig). Not runtime-tested; I do not have this hardware, and I
have not observed the race myself.
drivers/message/fusion/mptbase.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 3a431ffd3e2e..f6814c465175 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1985,9 +1985,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
INIT_LIST_HEAD(&ioc->fw_event_list);
spin_lock_init(&ioc->fw_event_lock);
- ioc->fw_event_q = alloc_workqueue("mpt/%d",
- WQ_MEM_RECLAIM | WQ_PERCPU, 0,
- ioc->id);
+ ioc->fw_event_q = alloc_ordered_workqueue("mpt/%d", WQ_MEM_RECLAIM,
+ ioc->id);
if (!ioc->fw_event_q) {
printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
ioc->name);
--
2.25.1