From: Ziyu Zhang <ziyuzhang201@gmail.com>
To: ian.ray@gehealthcare.com, david@ixit.cz
Cc: clement.perrochaud@nxp.com, sameo@linux.intel.com,
oe-linux-nfc@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, ziyuzhang201@gmail.com,
baijiaju1990@gmail.com
Subject: Re: [PATCH v2] NFC: nxp-nci: fix deadlock between firmware download and IRQ handler
Date: Mon, 23 Nov 2026 23:36:34 +0800 [thread overview]
Message-ID: <20261123153634.66973-1-ziyuzhang201@gmail.com> (raw)
In-Reply-To: <b707c629-97a7-4766-955b-64a2a7626004@ixit.cz>
Hi Ian and David,
Thanks for the patch and review.
For the timeout/late-response race David pointed out, I suggest checking
info->mode at the start of nxp_nci_fw_work(), after taking info_lock.
On timeout, nxp_nci_fw_work_complete() sets the mode to NXP_NCI_MODE_COLD
and releases the firmware while the worker holds info_lock. When the
work queued by a late response runs after this cleanup, the mode check
makes it exit before accessing the released firmware data.
The diff below combines Ian's unlock/wait/relock fix with this additional
check and applies to the original code before v2.
I have not fixed the other two issues yet. I think these would be best addressed in separate
patches.
Signed-off-by: Ziyu Zhang <ziyuzhang201@gmail.com>
---
drivers/nfc/nxp-nci/firmware.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/nfc/nxp-nci/firmware.c b/drivers/nfc/nxp-nci/firmware.c
index a953397..33193fe 100644
--- a/drivers/nfc/nxp-nci/firmware.c
+++ b/drivers/nfc/nxp-nci/firmware.c
@@ -154,8 +154,10 @@ static int nxp_nci_fw_send(struct nxp_nci_info *info)
if (fw_info->fw)
schedule_work(&fw_info->work);
} else {
+ mutex_unlock(&info->info_lock);
completion_rc = wait_for_completion_interruptible_timeout(
&fw_info->cmd_completion, NXP_NCI_FW_ANSWER_TIMEOUT);
+ mutex_lock(&info->info_lock);
if (completion_rc == 0)
return -ETIMEDOUT;
}
@@ -174,6 +176,9 @@ void nxp_nci_fw_work(struct work_struct *work)
mutex_lock(&info->info_lock);
+ if (info->mode != NXP_NCI_MODE_FW)
+ goto out_unlock;
+
r = fw_info->cmd_result;
if (r < 0)
goto exit_work;
@@ -190,6 +195,7 @@ void nxp_nci_fw_work(struct work_struct *work)
exit_work:
if (r < 0 || fw_info->size == 0)
nxp_nci_fw_work_complete(info, r);
+out_unlock:
mutex_unlock(&info->info_lock);
}
--
2.34.1
prev parent reply other threads:[~2026-11-23 15:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 8:21 Ian Ray
2026-08-11 17:32 ` David Heidelberg
2026-11-23 15:36 ` Ziyu Zhang [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=20261123153634.66973-1-ziyuzhang201@gmail.com \
--to=ziyuzhang201@gmail.com \
--cc=baijiaju1990@gmail.com \
--cc=clement.perrochaud@nxp.com \
--cc=david@ixit.cz \
--cc=ian.ray@gehealthcare.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oe-linux-nfc@lists.linux.dev \
--cc=sameo@linux.intel.com \
--cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®