wifi: mac80211: tighten locking check
authorJohannes Berg <johannes.berg@intel.com>
Wed, 6 Jul 2022 08:09:57 +0000 (10:09 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 15 Jul 2022 09:43:19 +0000 (11:43 +0200)
When we remove a link that doesn't have a channel context,
we don't really need the local->mtx locking. Tighten the
check here.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/chan.c

index 92fe405..5ab2107 100644 (file)
@@ -1991,10 +1991,11 @@ void ieee80211_link_release_channel(struct ieee80211_link_data *link)
 
        WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
 
-       lockdep_assert_held(&sdata->local->mtx);
-
        mutex_lock(&sdata->local->chanctx_mtx);
-       __ieee80211_link_release_channel(link);
+       if (rcu_access_pointer(link->conf->chanctx_conf)) {
+               lockdep_assert_held(&sdata->local->mtx);
+               __ieee80211_link_release_channel(link);
+       }
        mutex_unlock(&sdata->local->chanctx_mtx);
 }