Netdev List
 help / color / mirror / Atom feed
From: Shubham Antil <shubham@octane.security>
To: netdev@vger.kernel.org
Cc: Simon Horman <horms@kernel.org>,
	gio@octane.security, David Heidelberg <david@ixit.cz>,
	oe-linux-nfc@lists.linux.dev
Subject: [PATCH net v9 3/3] nfc: nfcmrvl: abort firmware work before unregistering
Date: Mon, 30 Nov 2026 18:32:40 +0530	[thread overview]
Message-ID: <20261130130240.65411-4-shubham@octane.security> (raw)
In-Reply-To: <20261130130240.65411-1-shubham@octane.security>

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 <shubham@octane.security>
---
 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


      parent reply	other threads:[~2026-11-30 13:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 13:02 [PATCH net v9 0/3] nfc: nfcmrvl: split firmware teardown fixes Shubham Antil
2026-11-30 13:02 ` [PATCH net v9 1/3] nfc: nci: add a pre-unregister shutdown stage Shubham Antil
2026-11-30 13:02 ` [PATCH net v9 2/3] nfc: nfcmrvl: serialize firmware completion and teardown Shubham Antil
2026-11-30 13:02 ` Shubham Antil [this message]

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=20261130130240.65411-4-shubham@octane.security \
    --to=shubham@octane.security \
    --cc=david@ixit.cz \
    --cc=gio@octane.security \
    --cc=horms@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oe-linux-nfc@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox