Skip to content

Commit 15846f9

Browse files
benzeajmberg-intel
authored andcommitted
wifi: mac80211: take lock before setting vif links
ieee80211_vif_set_links requires the sdata->local->mtx lock to be held. Add the appropriate locking around the calls in both the link add and remove handlers. This causes a warning when e.g. ieee80211_link_release_channel is called via ieee80211_link_stop from ieee80211_vif_update_links. Fixes: 0d8c4a3 ("wifi: mac80211: implement add/del interface link callbacks") Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> Link: https://lore.kernel.org/r/20230608163202.fa0c6597fdad.I83dd70359f6cda30f86df8418d929c2064cf4995@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 1ff5668 commit 15846f9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

net/mac80211/cfg.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4865,11 +4865,16 @@ static int ieee80211_add_intf_link(struct wiphy *wiphy,
48654865
unsigned int link_id)
48664866
{
48674867
struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4868+
int res;
48684869

48694870
if (wdev->use_4addr)
48704871
return -EOPNOTSUPP;
48714872

4872-
return ieee80211_vif_set_links(sdata, wdev->valid_links);
4873+
mutex_lock(&sdata->local->mtx);
4874+
res = ieee80211_vif_set_links(sdata, wdev->valid_links);
4875+
mutex_unlock(&sdata->local->mtx);
4876+
4877+
return res;
48734878
}
48744879

48754880
static void ieee80211_del_intf_link(struct wiphy *wiphy,
@@ -4878,7 +4883,9 @@ static void ieee80211_del_intf_link(struct wiphy *wiphy,
48784883
{
48794884
struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
48804885

4886+
mutex_lock(&sdata->local->mtx);
48814887
ieee80211_vif_set_links(sdata, wdev->valid_links);
4888+
mutex_unlock(&sdata->local->mtx);
48824889
}
48834890

48844891
static int sta_add_link_station(struct ieee80211_local *local,

0 commit comments

Comments
 (0)