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 <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2026-10-09 20:10:07 +02:00
parent 3938d944e8
commit fd6bcb455b

View File

@ -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;
}