wifi: cfg80211: track netdev running state under wiphy mutex

wdev_running() uses netif_running() for netdevs, which
can only be used under RTNL in a completely race-free
way.

Track the state for all wdevs via the existing netdev
notifier so we can check the state under wiphy mutex
in later changes.

Link: https://patch.msgid.link/20261006120655.7ed32b42c297.I9ac8bb8e7cd07c962116949aa0c56aab4e87839b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2026-10-06 12:04:00 +02:00
parent 298618f28b
commit bf49114633
2 changed files with 6 additions and 4 deletions

View File

@ -7242,8 +7242,9 @@ enum ieee80211_ap_reg_power {
* @mgmt_registrations_need_update: mgmt registrations were updated,
* need to propagate the update to the driver
* @address: The address for this device, valid only if @netdev is %NULL
* @is_running: true if this is a non-netdev device that has been started, e.g.
* the P2P Device.
* @is_running: true if the device has been started, e.g. the P2P Device;
* for netdevs, tracked under the wiphy mutex from NETDEV_UP until
* NETDEV_GOING_DOWN
* @ps: powersave mode is enabled
* @ps_timeout: dynamic powersave timeout
* @unexpected_nlportid: (private) netlink port ID of application
@ -7407,8 +7408,6 @@ static inline const u8 *wdev_address(struct wireless_dev *wdev)
static inline bool wdev_running(struct wireless_dev *wdev)
{
if (wdev->netdev)
return netif_running(wdev->netdev);
return wdev->is_running;
}

View File

@ -1836,6 +1836,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
}
break;
case NETDEV_GOING_DOWN:
scoped_guard(wiphy, &rdev->wiphy)
wdev->is_running = false;
cfg80211_leave(rdev, wdev, -1);
scoped_guard(wiphy, &rdev->wiphy) {
cfg80211_remove_links(wdev);
@ -1866,6 +1868,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
break;
case NETDEV_UP:
wiphy_lock(&rdev->wiphy);
wdev->is_running = true;
cfg80211_update_iface_num(rdev, wdev->iftype, 1);
switch (wdev->iftype) {
#ifdef CONFIG_CFG80211_WEXT