From fd6bcb455bf7d15165db1cbd325d53ad095fceee Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 9 Oct 2026 20:10:07 +0200 Subject: [PATCH] wifi: cfg80211: make cookie counter atomic The cookie counter is currently protected by the wiphy mutex, but in order to be able to transmit management frames without holding that, we need to assign cookies atomically. Link: https://patch.msgid.link/20261009201417.ec1dbc786a60.I83ec404d833100a798181234c797c558400c7145@changeid Signed-off-by: Johannes Berg --- net/wireless/core.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/wireless/core.h b/net/wireless/core.h index 0e05d4247bea..07d7a68a7cfc 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -83,7 +83,9 @@ struct cfg80211_registered_device { /* protected by RTNL only */ int num_running_ifaces; int num_running_monitor_ifaces; - u64 cookie_counter; + + /* atomic for unlocked users */ + atomic64_t cookie_counter; /* BSSes/scanning */ spinlock_t bss_lock; @@ -171,10 +173,10 @@ cfg80211_rdev_free_wowlan(struct cfg80211_registered_device *rdev) static inline u64 cfg80211_assign_cookie(struct cfg80211_registered_device *rdev) { - u64 r = ++rdev->cookie_counter; + u64 r = atomic64_inc_return(&rdev->cookie_counter); if (WARN_ON(r == 0)) - r = ++rdev->cookie_counter; + r = atomic64_inc_return(&rdev->cookie_counter); return r; }