# \[PATCH net\] psp: use unrcu\_pointer() for the cmpxchg() on netdev psp\_dev

- From: Wei Wang \<hidden\>
- Date: 2026-08-13 19:34:21 
- List: netdev
- Page: https://ratatoskr.run/netdev/2026/08/17409508
- Thread: https://ratatoskr.run/netdev/2026/08/17409508/t.md

```text
From: Wei Wang <redacted>

sparse reports:

  net/psp/psp_nl.c:513:13: sparse: sparse: cast removes address space
  '__rcu' of expression

cmpxchg() returns typeof(*ptr) and its internal casts strip the __rcu
annotation. Wrap it in unrcu_pointer(), the documented way to use an
__rcu pointer with xchg() and friends.

This was introduced by commit 06c2dce2d0f6 ("psp: add new netlink cmd
for dev-assoc and dev-disassoc").

No functional change intended.

Reported-by: kernel test robot <redacted>
Closes: https://lore.kernel.org/oe-kbuild-all/202608080910.l9KvOH7O-lkp@intel.com/
Signed-off-by: Wei Wang <redacted>
---
 net/psp/psp_nl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/psp/psp_nl.c b/net/psp/psp_nl.c
index 43b066353c65..f91665748dde 100644
--- a/net/psp/psp_nl.c
+++ b/net/psp/psp_nl.c
@@ -533,7 +533,8 @@ int psp_nl_dev_assoc_doit(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	/* Check if device is already associated with a PSP device */
-	if (cmpxchg(&assoc_dev->psp_dev, NULL, RCU_INITIALIZER(psd))) {
+	if (unrcu_pointer(cmpxchg(&assoc_dev->psp_dev, NULL,
+				  RCU_INITIALIZER(psd)))) {
 		NL_SET_ERR_MSG(info->extack,
 			       "Device already associated with a PSP device");
 		err = -EBUSY;
-- 
2.53.0-Meta

```
