]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nfc: nci: clear NCI_DATA_EXCHANGE before calling completion callback
authorJakub Kicinski <kuba@kernel.org>
Tue, 3 Mar 2026 16:23:44 +0000 (08:23 -0800)
committerSasha Levin <sashal@kernel.org>
Thu, 12 Mar 2026 11:09:57 +0000 (07:09 -0400)
commit28c9be1ef8bb183e207978c487beafb3a99dafe4
treece98c19365c3f004861fdef284c37d52bf089bed
parentd05f55d68ebdebb2b0a8480d766eaae88c8c92de
nfc: nci: clear NCI_DATA_EXCHANGE before calling completion callback

[ Upstream commit 0efdc02f4f6d52f8ca5d5889560f325a836ce0a8 ]

Move clear_bit(NCI_DATA_EXCHANGE) before invoking the data exchange
callback in nci_data_exchange_complete().

The callback (e.g. rawsock_data_exchange_complete) may immediately
schedule another data exchange via schedule_work(tx_work).  On a
multi-CPU system, tx_work can run and reach nci_transceive() before
the current nci_data_exchange_complete() clears the flag, causing
test_and_set_bit(NCI_DATA_EXCHANGE) to return -EBUSY and the new
transfer to fail.

This causes intermittent flakes in nci/nci_dev in NIPA:

  # #  RUN           NCI.NCI1_0.t4t_tag_read ...
  # # t4t_tag_read: Test terminated by timeout
  # #          FAIL  NCI.NCI1_0.t4t_tag_read
  # not ok 3 NCI.NCI1_0.t4t_tag_read

Fixes: 38f04c6b1b68 ("NFC: protect nci_data_exchange transactions")
Reviewed-by: Joe Damato <joe@dama.to>
Link: https://patch.msgid.link/20260303162346.2071888-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/nfc/nci/data.c