nfcmrvl_nci_unregister_dev() destroys the NCI workqueues before draining firmware receive work. That worker may still submit NCI commands, and the later firmware cleanup can release state the worker is using. Abort an active download from the NCI shutdown callback, after core admission has closed but before its workqueues are destroyed. Keep final firmware workqueue destruction separate so unregister does not execute the abort path twice. Discovered during an AI-assisted source audit using OpenAI Codex, gpt-5.6-sol. The active-download detach condition was reproduced at runtime by starting a firmware download and removing the N_NCI line discipline. One hundred immediate detach iterations and timed completion-boundary modes were exercised. No production incident or pre-fix sanitizer report was captured. Patch development and test planning used the same assistant. No physical NFC controller was available. Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support") Assisted-by: LLM (OpenAI Codex, gpt-5.6-sol) Signed-off-by: Shubham Antil --- drivers/nfc/nfcmrvl/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/nfc/nfcmrvl/main.c b/drivers/nfc/nfcmrvl/main.c index 6efa83219..7677bcaf5 100644 --- a/drivers/nfc/nfcmrvl/main.c +++ b/drivers/nfc/nfcmrvl/main.c @@ -67,6 +67,13 @@ static int nfcmrvl_nci_send(struct nci_dev *ndev, struct sk_buff *skb) return priv->if_ops->nci_send(priv, skb); } +static void nfcmrvl_nci_shutdown(struct nci_dev *ndev) +{ + struct nfcmrvl_private *priv = nci_get_drvdata(ndev); + + nfcmrvl_fw_dnld_abort(priv); +} + static int nfcmrvl_nci_setup(struct nci_dev *ndev) { __u8 val = 1; @@ -85,6 +92,7 @@ static const struct nci_ops nfcmrvl_nci_ops = { .open = nfcmrvl_nci_open, .close = nfcmrvl_nci_close, .send = nfcmrvl_nci_send, + .shutdown = nfcmrvl_nci_shutdown, .setup = nfcmrvl_nci_setup, .fw_download = nfcmrvl_nci_fw_download, }; @@ -181,8 +189,6 @@ void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv) struct nci_dev *ndev = priv->ndev; nci_unregister_device(ndev); - if (priv->ndev->nfc_dev->fw_download_in_progress) - nfcmrvl_fw_dnld_abort(priv); nfcmrvl_fw_dnld_deinit(priv); -- 2.54.0