[PATCH v2] misc: ocxl: cancel XSL fault work before freeing SPA

From: Hongyan Xu

Date: Sun Nov 15 2026 - 06:48:49 EST


The XSL fault interrupt takes an mm reference and queues fault_work
embedded in the SPA. free_irq() stops new interrupt handlers but does
not drain an already queued worker, allowing free_spa() to release its
container first.

Cancel the work after freeing the interrupt. When cancellation removes a
pending instance, also drop the mm reference that the worker would have
released.

Changes in v2: cancel the work after free_irq() and drop the mm
reference when a pending instance was removed, and refresh the comment
that explains the ordering.

Found by the author's in-house static analysis tool.

Fixes: 5ef3166e8a32 ("ocxl: Driver code for 'generic' opencapi devices")
Cc: stable@xxxxxxxxxxxxxxx
Link: https://lore.kernel.org/all/20260928134110.227-1-getshell@xxxxxxxxxx/
Signed-off-by: Hongyan Xu <getshell@xxxxxxxxxx>
Signed-off-by: Zehao Gao <gaozehao@xxxxxxxxx>
---

Discovery: found by the author's in-house static analysis tool.

drivers/misc/ocxl/link.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
index 7749dcd..a0220af 100644
--- a/drivers/misc/ocxl/link.c
+++ b/drivers/misc/ocxl/link.c
@@ -252,7 +252,11 @@ static irqreturn_t xsl_fault_handler(int irq, void *data)
spa->xsl_fault.dsisr = dsisr;
spa->xsl_fault.pe_data = *pe_data;
schedule = true;
- /* mm_users count released by bottom half */
+ /*
+ * The bottom half drops the mm_users reference, or
+ * release_xsl_irq() does when the work is still pending
+ * and gets canceled during teardown.
+ */
}
rcu_read_unlock();
if (schedule)
@@ -335,6 +339,8 @@ static void release_xsl_irq(struct ocxl_link *link)

if (spa->virq) {
free_irq(spa->virq, link);
+ if (cancel_work_sync(&spa->xsl_fault.fault_work))
+ mmput(spa->xsl_fault.pe_data.mm);
irq_dispose_mapping(spa->virq);
}
kfree(spa->irq_name);
--
2.50.1.windows.1