netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]nfc: replace improper check device_is_registered() in nfc_se_io()
@ 2025-04-14 14:11 Chen Yufeng
  2025-04-14 14:55 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 6+ messages in thread
From: Chen Yufeng @ 2025-04-14 14:11 UTC (permalink / raw)
  To: krzk; +Cc: davem, edumazet, kuba, pabeni, horms, netdev, Chen Yufeng

A patch similar to commit da5c0f119203 ("nfc: replace improper check device_is_registered() in netlink related functions")

The nfc_se_io() function in the NFC subsystem suffers from a race 
condition similar to previously reported issues in other netlink-related 
functions. The function checks device status using device_is_registered(),
but this check can race with device unregistration despite being protected
by device_lock.

This patch also uses bool variable dev->shutting_down instead of
device_is_registered() to judge whether the nfc device is registered,
which is well synchronized.

Signed-off-by: Chen Yufeng <chenyufeng@iie.ac.cn>
---
 net/nfc/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 6a40b8d0350d..6de0f5a18a87 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1426,7 +1426,7 @@ static int nfc_se_io(struct nfc_dev *dev, u32 se_idx,
 
 	device_lock(&dev->dev);
 
-	if (!device_is_registered(&dev->dev)) {
+	if (dev->shutting_down) {
 		rc = -ENODEV;
 		goto error;
 	}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-04-16  2:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14 14:11 [PATCH]nfc: replace improper check device_is_registered() in nfc_se_io() Chen Yufeng
2025-04-14 14:55 ` Krzysztof Kozlowski
2025-04-15  2:54   ` Chen Yufeng
2025-04-16  0:38     ` Jakub Kicinski
2025-04-16  2:33       ` Chen Yufeng
2025-04-16  2:44       ` Chen Yufeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).