From bf49114633184715a128978969aca3f4d98bd034 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Oct 2026 12:04:00 +0200 Subject: [PATCH] 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 --- include/net/cfg80211.h | 7 +++---- net/wireless/core.c | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index a3fb7dd743c8..d4a77f9fe0b7 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -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; } diff --git a/net/wireless/core.c b/net/wireless/core.c index 45a1709cffe7..fa56208f8c8e 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -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