Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: cfg80211: remove wdev mutex

Since we're now protecting everything with the wiphy mutex
(and were really using it for almost everything before),
there's no longer any real reason to have a separate wdev
mutex. It may feel better, but really has no value.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+302 -976
+2 -2
drivers/net/wireless/ath/ath6kl/cfg80211.c
··· 1118 1118 ath6kl_band_2ghz.ht_cap.ht_supported) ? 1119 1119 NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT); 1120 1120 1121 - mutex_lock(&vif->wdev.mtx); 1121 + wiphy_lock(vif->ar->wiphy); 1122 1122 cfg80211_ch_switch_notify(vif->ndev, &chandef, 0, 0); 1123 - mutex_unlock(&vif->wdev.mtx); 1123 + wiphy_unlock(vif->ar->wiphy); 1124 1124 } 1125 1125 1126 1126 static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
+2 -2
drivers/net/wireless/marvell/mwifiex/11h.c
··· 287 287 288 288 mwifiex_dbg(priv->adapter, MSG, 289 289 "indicating channel switch completion to kernel\n"); 290 - mutex_lock(&priv->wdev.mtx); 290 + wiphy_lock(priv->wdev.wiphy); 291 291 cfg80211_ch_switch_notify(priv->netdev, &priv->dfs_chandef, 0, 0); 292 - mutex_unlock(&priv->wdev.mtx); 292 + wiphy_unlock(priv->wdev.wiphy); 293 293 }
+2 -2
drivers/net/wireless/quantenna/qtnfmac/event.c
··· 477 477 if (!vif->netdev) 478 478 continue; 479 479 480 - mutex_lock(&vif->wdev.mtx); 480 + wiphy_lock(priv_to_wiphy(vif->mac)); 481 481 cfg80211_ch_switch_notify(vif->netdev, &chandef, 0, 0); 482 - mutex_unlock(&vif->wdev.mtx); 482 + wiphy_unlock(priv_to_wiphy(vif->mac)); 483 483 } 484 484 485 485 return 0;
+1 -5
include/net/cfg80211.h
··· 5938 5938 * @mgmt_registrations: list of registrations for management frames 5939 5939 * @mgmt_registrations_need_update: mgmt registrations were updated, 5940 5940 * need to propagate the update to the driver 5941 - * @mtx: mutex used to lock data in this struct, may be used by drivers 5942 - * and some API functions require it held 5943 5941 * @beacon_interval: beacon interval used on this device for transmitting 5944 5942 * beacons, 0 when not valid 5945 5943 * @address: The address for this device, valid only if @netdev is %NULL ··· 5982 5984 5983 5985 struct list_head mgmt_registrations; 5984 5986 u8 mgmt_registrations_need_update:1; 5985 - 5986 - struct mutex mtx; 5987 5987 5988 5988 bool use_4addr, is_running, registered, registering; 5989 5989 ··· 8585 8589 * @link_id: the link ID for MLO, must be 0 for non-MLO 8586 8590 * @punct_bitmap: the new puncturing bitmap 8587 8591 * 8588 - * Caller must acquire wdev_lock, therefore must only be called from sleepable 8592 + * Caller must hold wiphy mutex, therefore must only be called from sleepable 8589 8593 * driver context! 8590 8594 */ 8591 8595 void cfg80211_ch_switch_notify(struct net_device *dev,
+6 -14
include/net/mac80211.h
··· 643 643 * @pwr_reduction: power constraint of BSS. 644 644 * @eht_support: does this BSS support EHT 645 645 * @eht_puncturing: bitmap to indicate which channels are punctured in this BSS 646 - * @csa_active: marks whether a channel switch is going on. Internally it is 647 - * write-protected by sdata_lock and local->mtx so holding either is fine 648 - * for read access. 646 + * @csa_active: marks whether a channel switch is going on. 649 647 * @csa_punct_bitmap: new puncturing bitmap for channel switch 650 648 * @mu_mimo_owner: indicates interface owns MU-MIMO capability 651 649 * @chanctx_conf: The channel context this interface is assigned to, or %NULL ··· 651 653 * path needing to access it; even though the netdev carrier will always 652 654 * be off when it is %NULL there can still be races and packets could be 653 655 * processed after it switches back to %NULL. 654 - * @color_change_active: marks whether a color change is ongoing. Internally it is 655 - * write-protected by sdata_lock and local->mtx so holding either is fine 656 - * for read access. 656 + * @color_change_active: marks whether a color change is ongoing. 657 657 * @color_change_color: the bss color that will be used after the change. 658 658 * @ht_ldpc: in AP mode, indicates interface has HT LDPC capability. 659 659 * @vht_ldpc: in AP mode, indicates interface has VHT LDPC capability. ··· 1970 1974 */ 1971 1975 struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif); 1972 1976 1973 - /** 1974 - * lockdep_vif_mutex_held - for lockdep checks on link poiners 1975 - * @vif: the interface to check 1976 - */ 1977 - static inline bool lockdep_vif_mutex_held(struct ieee80211_vif *vif) 1977 + static inline bool lockdep_vif_wiphy_mutex_held(struct ieee80211_vif *vif) 1978 1978 { 1979 - return lockdep_is_held(&ieee80211_vif_to_wdev(vif)->mtx); 1979 + return lockdep_is_held(&ieee80211_vif_to_wdev(vif)->wiphy->mtx); 1980 1980 } 1981 1981 1982 1982 #define link_conf_dereference_protected(vif, link_id) \ 1983 1983 rcu_dereference_protected((vif)->link_conf[link_id], \ 1984 - lockdep_vif_mutex_held(vif)) 1984 + lockdep_vif_wiphy_mutex_held(vif)) 1985 1985 1986 1986 #define link_conf_dereference_check(vif, link_id) \ 1987 1987 rcu_dereference_check((vif)->link_conf[link_id], \ 1988 - lockdep_vif_mutex_held(vif)) 1988 + lockdep_vif_wiphy_mutex_held(vif)) 1989 1989 1990 1990 /** 1991 1991 * enum ieee80211_key_flags - key flags
+8 -35
net/mac80211/cfg.c
··· 573 573 struct ieee80211_key *key; 574 574 575 575 if (link_id >= 0) { 576 - link = rcu_dereference_check(sdata->link[link_id], 577 - lockdep_is_held(&sdata->wdev.mtx)); 576 + link = sdata_dereference(sdata->link[link_id], sdata); 578 577 if (!link) 579 578 return NULL; 580 579 } ··· 895 896 sdata = wiphy_dereference(local->hw.wiphy, 896 897 local->monitor_sdata); 897 898 if (sdata) { 898 - sdata_lock(sdata); 899 899 ieee80211_link_release_channel(&sdata->deflink); 900 900 ret = ieee80211_link_use_channel(&sdata->deflink, 901 901 chandef, 902 902 IEEE80211_CHANCTX_EXCLUSIVE); 903 - sdata_unlock(sdata); 904 903 } 905 904 } else { 906 905 if (local->open_count == local->monitors) { ··· 1487 1490 struct ieee80211_bss_conf *link_conf; 1488 1491 u64 changed = 0; 1489 1492 1490 - sdata_assert_lock(sdata); 1493 + lockdep_assert_wiphy(wiphy); 1491 1494 1492 1495 link = sdata_dereference(sdata->link[params->link_id], sdata); 1493 1496 if (!link) ··· 1546 1549 sdata_dereference(sdata->link[link_id], sdata); 1547 1550 struct ieee80211_bss_conf *link_conf = link->conf; 1548 1551 1549 - sdata_assert_lock(sdata); 1550 1552 lockdep_assert_wiphy(local->hw.wiphy); 1551 1553 1552 1554 old_beacon = sdata_dereference(link->u.ap.beacon, sdata); ··· 2159 2163 } 2160 2164 } 2161 2165 2162 - /* we use sta_info_get_bss() so this might be different */ 2163 - if (sdata != sta->sdata) { 2164 - mutex_lock_nested(&sta->sdata->wdev.mtx, 1); 2165 - err = sta_apply_parameters(local, sta, params); 2166 - mutex_unlock(&sta->sdata->wdev.mtx); 2167 - } else { 2168 - err = sta_apply_parameters(local, sta, params); 2169 - } 2166 + err = sta_apply_parameters(local, sta, params); 2170 2167 if (err) 2171 2168 return err; 2172 2169 ··· 3121 3132 struct sta_info *sta; 3122 3133 bool tdls_peer_found = false; 3123 3134 3124 - lockdep_assert_held(&sdata->wdev.mtx); 3135 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 3125 3136 3126 3137 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) 3127 3138 return -EINVAL; ··· 3200 3211 local->dynamic_ps_forced_timeout = timeout; 3201 3212 3202 3213 /* no change, but if automatic follow powersave */ 3203 - sdata_lock(sdata); 3204 3214 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) { 3205 3215 struct ieee80211_link_data *link; 3206 3216 ··· 3210 3222 __ieee80211_request_smps_mgd(sdata, link, 3211 3223 link->u.mgd.req_smps); 3212 3224 } 3213 - sdata_unlock(sdata); 3214 3225 3215 3226 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) 3216 3227 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); ··· 3596 3609 u64 changed = 0; 3597 3610 int err; 3598 3611 3599 - sdata_assert_lock(sdata); 3600 3612 lockdep_assert_wiphy(local->hw.wiphy); 3601 3613 3602 3614 /* ··· 3667 3681 deflink.csa_finalize_work); 3668 3682 struct ieee80211_local *local = sdata->local; 3669 3683 3670 - sdata_lock(sdata); 3671 3684 lockdep_assert_wiphy(local->hw.wiphy); 3672 3685 3673 3686 /* AP might have been stopped while waiting for the lock. */ 3674 3687 if (!sdata->vif.bss_conf.csa_active) 3675 - goto unlock; 3688 + return; 3676 3689 3677 3690 if (!ieee80211_sdata_running(sdata)) 3678 - goto unlock; 3691 + return; 3679 3692 3680 3693 ieee80211_csa_finalize(sdata); 3681 - 3682 - unlock: 3683 - sdata_unlock(sdata); 3684 3694 } 3685 3695 3686 3696 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata, ··· 3832 3850 u64 changed = 0; 3833 3851 int err; 3834 3852 3835 - sdata_assert_lock(sdata); 3836 3853 lockdep_assert_wiphy(local->hw.wiphy); 3837 3854 3838 3855 if (!list_empty(&local->roc_list) || local->scanning) ··· 4646 4665 u64 changed = 0; 4647 4666 int err; 4648 4667 4649 - sdata_assert_lock(sdata); 4650 4668 lockdep_assert_wiphy(local->hw.wiphy); 4651 4669 4652 4670 sdata->vif.bss_conf.color_change_active = false; ··· 4672 4692 deflink.color_change_finalize_work); 4673 4693 struct ieee80211_local *local = sdata->local; 4674 4694 4675 - sdata_lock(sdata); 4676 4695 lockdep_assert_wiphy(local->hw.wiphy); 4677 4696 4678 4697 /* AP might have been stopped while waiting for the lock. */ 4679 4698 if (!sdata->vif.bss_conf.color_change_active) 4680 - goto unlock; 4699 + return; 4681 4700 4682 4701 if (!ieee80211_sdata_running(sdata)) 4683 - goto unlock; 4702 + return; 4684 4703 4685 4704 ieee80211_color_change_finalize(sdata); 4686 - 4687 - unlock: 4688 - sdata_unlock(sdata); 4689 4705 } 4690 4706 4691 4707 void ieee80211_color_collision_detection_work(struct work_struct *work) ··· 4692 4716 color_collision_detect_work); 4693 4717 struct ieee80211_sub_if_data *sdata = link->sdata; 4694 4718 4695 - sdata_lock(sdata); 4696 4719 cfg80211_obss_color_collision_notify(sdata->dev, link->color_bitmap); 4697 - sdata_unlock(sdata); 4698 4720 } 4699 4721 4700 4722 void ieee80211_color_change_finish(struct ieee80211_vif *vif) ··· 4736 4762 u64 changed = 0; 4737 4763 int err; 4738 4764 4739 - sdata_assert_lock(sdata); 4740 4765 lockdep_assert_wiphy(local->hw.wiphy); 4741 4766 4742 4767 if (sdata->vif.bss_conf.nontransmitted)
+1 -9
net/mac80211/debugfs_netdev.c
··· 322 322 { 323 323 struct ieee80211_sub_if_data *sdata = link->sdata; 324 324 struct ieee80211_local *local = sdata->local; 325 - int err; 326 325 327 326 if (sdata->vif.driver_flags & IEEE80211_VIF_DISABLE_SMPS_OVERRIDE) 328 327 return -EOPNOTSUPP; ··· 339 340 if (sdata->vif.type != NL80211_IFTYPE_STATION) 340 341 return -EOPNOTSUPP; 341 342 342 - sdata_lock(sdata); 343 - err = __ieee80211_request_smps_mgd(link->sdata, link, smps_mode); 344 - sdata_unlock(sdata); 345 - 346 - return err; 343 + return __ieee80211_request_smps_mgd(link->sdata, link, smps_mode); 347 344 } 348 345 349 346 static const char *smps_modes[IEEE80211_SMPS_NUM_MODES] = { ··· 411 416 case NL80211_IFTYPE_STATION: 412 417 fc |= cpu_to_le16(IEEE80211_FCTL_TODS); 413 418 /* BSSID SA DA */ 414 - sdata_lock(sdata); 415 419 if (!sdata->u.mgd.associated) { 416 - sdata_unlock(sdata); 417 420 dev_kfree_skb(skb); 418 421 return -ENOTCONN; 419 422 } 420 423 memcpy(hdr->addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); 421 424 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); 422 425 memcpy(hdr->addr3, addr, ETH_ALEN); 423 - sdata_unlock(sdata); 424 426 break; 425 427 default: 426 428 dev_kfree_skb(skb);
-2
net/mac80211/driver-ops.c
··· 300 300 might_sleep(); 301 301 lockdep_assert_wiphy(local->hw.wiphy); 302 302 303 - drv_verify_link_exists(sdata, link_conf); 304 303 if (!check_sdata_in_driver(sdata)) 305 304 return -EIO; 306 305 ··· 328 329 might_sleep(); 329 330 lockdep_assert_wiphy(local->hw.wiphy); 330 331 331 - drv_verify_link_exists(sdata, link_conf); 332 332 if (!check_sdata_in_driver(sdata)) 333 333 return; 334 334
-14
net/mac80211/driver-ops.h
··· 996 996 trace_drv_return_void(local); 997 997 } 998 998 999 - static inline void drv_verify_link_exists(struct ieee80211_sub_if_data *sdata, 1000 - struct ieee80211_bss_conf *link_conf) 1001 - { 1002 - /* deflink always exists, so need to check only for other links */ 1003 - if (sdata->deflink.conf != link_conf) 1004 - sdata_assert_lock(sdata); 1005 - } 1006 - 1007 999 int drv_assign_vif_chanctx(struct ieee80211_local *local, 1008 1000 struct ieee80211_sub_if_data *sdata, 1009 1001 struct ieee80211_bss_conf *link_conf, ··· 1013 1021 struct ieee80211_bss_conf *link_conf) 1014 1022 { 1015 1023 int ret = 0; 1016 - 1017 - /* make sure link_conf is protected */ 1018 - drv_verify_link_exists(sdata, link_conf); 1019 1024 1020 1025 might_sleep(); 1021 1026 lockdep_assert_wiphy(local->hw.wiphy); ··· 1033 1044 { 1034 1045 might_sleep(); 1035 1046 lockdep_assert_wiphy(local->hw.wiphy); 1036 - 1037 - /* make sure link_conf is protected */ 1038 - drv_verify_link_exists(sdata, link_conf); 1039 1047 1040 1048 if (!check_sdata_in_driver(sdata)) 1041 1049 return;
+12 -27
net/mac80211/ibss.c
··· 235 235 bool radar_required; 236 236 int err; 237 237 238 - sdata_assert_lock(sdata); 239 238 lockdep_assert_wiphy(local->hw.wiphy); 240 239 241 240 /* Reset own TSF to allow time synchronization work. */ ··· 402 403 u32 rate_flags; 403 404 int shift; 404 405 405 - sdata_assert_lock(sdata); 406 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 406 407 407 408 if (beacon_int < 10) 408 409 beacon_int = 10; ··· 483 484 u16 capability = WLAN_CAPABILITY_IBSS; 484 485 u64 tsf; 485 486 486 - sdata_assert_lock(sdata); 487 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 487 488 488 489 if (ifibss->privacy) 489 490 capability |= WLAN_CAPABILITY_PRIVACY; ··· 525 526 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 526 527 struct cfg80211_bss *cbss; 527 528 528 - sdata_assert_lock(sdata); 529 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 529 530 530 531 /* When not connected/joined, sending CSA doesn't make sense. */ 531 532 if (ifibss->state != IEEE80211_IBSS_MLME_JOINED) ··· 647 648 int active = 0; 648 649 struct sta_info *sta; 649 650 650 - sdata_assert_lock(sdata); 651 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 651 652 652 653 rcu_read_lock(); 653 654 ··· 733 734 container_of(work, struct ieee80211_sub_if_data, 734 735 u.ibss.csa_connection_drop_work); 735 736 736 - sdata_lock(sdata); 737 - 738 737 ieee80211_ibss_disconnect(sdata); 739 738 synchronize_rcu(); 740 739 skb_queue_purge(&sdata->skb_queue); 741 740 742 741 /* trigger a scan to find another IBSS network to join */ 743 742 wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work); 744 - 745 - sdata_unlock(sdata); 746 743 } 747 744 748 745 static void ieee80211_ibss_csa_mark_radar(struct ieee80211_sub_if_data *sdata) ··· 770 775 ieee80211_conn_flags_t conn_flags; 771 776 u32 vht_cap_info = 0; 772 777 773 - sdata_assert_lock(sdata); 778 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 774 779 775 780 conn_flags = IEEE80211_CONN_DISABLE_VHT; 776 781 ··· 942 947 { 943 948 u16 auth_alg, auth_transaction; 944 949 945 - sdata_assert_lock(sdata); 950 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 946 951 947 952 if (len < 24 + 6) 948 953 return; ··· 1284 1289 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 1285 1290 enum nl80211_bss_scan_width scan_width; 1286 1291 1287 - sdata_assert_lock(sdata); 1292 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1288 1293 1289 1294 mod_timer(&ifibss->timer, 1290 1295 round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL)); ··· 1316 1321 u16 capability; 1317 1322 int i; 1318 1323 1319 - sdata_assert_lock(sdata); 1324 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1320 1325 1321 1326 if (ifibss->fixed_bssid) { 1322 1327 memcpy(bssid, ifibss->bssid, ETH_ALEN); ··· 1427 1432 enum nl80211_bss_scan_width scan_width; 1428 1433 int active_ibss; 1429 1434 1430 - sdata_assert_lock(sdata); 1435 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1431 1436 1432 1437 active_ibss = ieee80211_sta_active_ibss(sdata); 1433 1438 ibss_dbg(sdata, "sta_find_ibss (active_ibss=%d)\n", active_ibss); ··· 1521 1526 struct beacon_data *presp; 1522 1527 u8 *pos, *end; 1523 1528 1524 - sdata_assert_lock(sdata); 1529 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1525 1530 1526 1531 presp = sdata_dereference(ifibss->presp, sdata); 1527 1532 ··· 1617 1622 mgmt = (struct ieee80211_mgmt *) skb->data; 1618 1623 fc = le16_to_cpu(mgmt->frame_control); 1619 1624 1620 - sdata_lock(sdata); 1621 - 1622 1625 if (!sdata->u.ibss.ssid_len) 1623 - goto mgmt_out; /* not ready to merge yet */ 1626 + return; /* not ready to merge yet */ 1624 1627 1625 1628 switch (fc & IEEE80211_FCTL_STYPE) { 1626 1629 case IEEE80211_STYPE_PROBE_REQ: ··· 1658 1665 break; 1659 1666 } 1660 1667 } 1661 - 1662 - mgmt_out: 1663 - sdata_unlock(sdata); 1664 1668 } 1665 1669 1666 1670 void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata) ··· 1665 1675 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 1666 1676 struct sta_info *sta; 1667 1677 1668 - sdata_lock(sdata); 1669 - 1670 1678 /* 1671 1679 * Work could be scheduled after scan or similar 1672 1680 * when we aren't even joined (or trying) with a 1673 1681 * network. 1674 1682 */ 1675 1683 if (!ifibss->ssid_len) 1676 - goto out; 1684 + return; 1677 1685 1678 1686 spin_lock_bh(&ifibss->incomplete_lock); 1679 1687 while (!list_empty(&ifibss->incomplete_stations)) { ··· 1697 1709 WARN_ON(1); 1698 1710 break; 1699 1711 } 1700 - 1701 - out: 1702 - sdata_unlock(sdata); 1703 1712 } 1704 1713 1705 1714 static void ieee80211_ibss_timer(struct timer_list *t)
+6 -24
net/mac80211/ieee80211_i.h
··· 991 991 struct ieee80211_key __rcu *default_beacon_key; 992 992 993 993 struct wiphy_work csa_finalize_work; 994 - bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */ 994 + bool csa_block_tx; 995 995 996 996 bool operating_11g_mode; 997 997 ··· 1135 1135 return container_of(p, struct ieee80211_sub_if_data, vif); 1136 1136 } 1137 1137 1138 - static inline void sdata_lock(struct ieee80211_sub_if_data *sdata) 1139 - __acquires(&sdata->wdev.mtx) 1140 - { 1141 - mutex_lock(&sdata->wdev.mtx); 1142 - __acquire(&sdata->wdev.mtx); 1143 - } 1144 - 1145 - static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata) 1146 - __releases(&sdata->wdev.mtx) 1147 - { 1148 - mutex_unlock(&sdata->wdev.mtx); 1149 - __release(&sdata->wdev.mtx); 1150 - } 1151 - 1152 1138 #define sdata_dereference(p, sdata) \ 1153 - rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx)) 1154 - 1155 - static inline void 1156 - sdata_assert_lock(struct ieee80211_sub_if_data *sdata) 1157 - { 1158 - lockdep_assert_held(&sdata->wdev.mtx); 1159 - } 1139 + wiphy_dereference(sdata->local->hw.wiphy, p) 1160 1140 1161 1141 static inline int 1162 1142 ieee80211_chanwidth_get_shift(enum nl80211_chan_width width) ··· 2014 2034 void ieee80211_link_stop(struct ieee80211_link_data *link); 2015 2035 int ieee80211_vif_set_links(struct ieee80211_sub_if_data *sdata, 2016 2036 u16 new_links, u16 dormant_links); 2017 - void ieee80211_vif_clear_links(struct ieee80211_sub_if_data *sdata); 2018 - int __ieee80211_set_active_links(struct ieee80211_vif *vif, u16 active_links); 2037 + static inline void ieee80211_vif_clear_links(struct ieee80211_sub_if_data *sdata) 2038 + { 2039 + ieee80211_vif_set_links(sdata, 0, 0); 2040 + } 2019 2041 2020 2042 /* tx handling */ 2021 2043 void ieee80211_clear_tx_pending(struct ieee80211_local *local);
-11
net/mac80211/iface.c
··· 529 529 del_timer_sync(&local->dynamic_ps_timer); 530 530 wiphy_work_cancel(local->hw.wiphy, &local->dynamic_ps_enable_work); 531 531 532 - sdata_lock(sdata); 533 532 WARN(ieee80211_vif_is_mld(&sdata->vif), 534 533 "destroying interface with valid links 0x%04x\n", 535 534 sdata->vif.valid_links); ··· 541 542 IEEE80211_QUEUE_STOP_REASON_CSA); 542 543 sdata->deflink.csa_block_tx = false; 543 544 } 544 - sdata_unlock(sdata); 545 545 546 546 wiphy_work_cancel(local->hw.wiphy, &sdata->deflink.csa_finalize_work); 547 547 wiphy_work_cancel(local->hw.wiphy, ··· 1131 1133 snprintf(sdata->name, IFNAMSIZ, "%s-monitor", 1132 1134 wiphy_name(local->hw.wiphy)); 1133 1135 sdata->wdev.iftype = NL80211_IFTYPE_MONITOR; 1134 - mutex_init(&sdata->wdev.mtx); 1135 1136 sdata->wdev.wiphy = local->hw.wiphy; 1136 1137 1137 1138 ieee80211_sdata_init(local, sdata); ··· 1156 1159 rcu_assign_pointer(local->monitor_sdata, sdata); 1157 1160 mutex_unlock(&local->iflist_mtx); 1158 1161 1159 - sdata_lock(sdata); 1160 1162 ret = ieee80211_link_use_channel(&sdata->deflink, &local->monitor_chandef, 1161 1163 IEEE80211_CHANCTX_EXCLUSIVE); 1162 - sdata_unlock(sdata); 1163 1164 if (ret) { 1164 1165 mutex_lock(&local->iflist_mtx); 1165 1166 RCU_INIT_POINTER(local->monitor_sdata, NULL); 1166 1167 mutex_unlock(&local->iflist_mtx); 1167 1168 synchronize_net(); 1168 1169 drv_remove_interface(local, sdata); 1169 - mutex_destroy(&sdata->wdev.mtx); 1170 1170 kfree(sdata); 1171 1171 return ret; 1172 1172 } ··· 1199 1205 1200 1206 synchronize_net(); 1201 1207 1202 - sdata_lock(sdata); 1203 1208 ieee80211_link_release_channel(&sdata->deflink); 1204 - sdata_unlock(sdata); 1205 1209 1206 1210 drv_remove_interface(local, sdata); 1207 1211 1208 - mutex_destroy(&sdata->wdev.mtx); 1209 1212 kfree(sdata); 1210 1213 } 1211 1214 ··· 2270 2279 * we can't acquire the wiphy_lock() again there if already 2271 2280 * inside this locked section. 2272 2281 */ 2273 - sdata_lock(sdata); 2274 2282 sdata->vif.cfg.arp_addr_cnt = 0; 2275 2283 if (sdata->vif.type == NL80211_IFTYPE_STATION && 2276 2284 sdata->u.mgd.associated) 2277 2285 ieee80211_vif_cfg_change_notify(sdata, 2278 2286 BSS_CHANGED_ARP_FILTER); 2279 - sdata_unlock(sdata); 2280 2287 2281 2288 list_del(&sdata->list); 2282 2289 cfg80211_unregister_wdev(&sdata->wdev);
+2 -32
net/mac80211/link.c
··· 191 191 struct ieee80211_link_data *old_data[IEEE80211_MLD_MAX_NUM_LINKS]; 192 192 bool use_deflink = old_links == 0; /* set for error case */ 193 193 194 - sdata_assert_lock(sdata); 194 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 195 195 196 196 memset(to_free, 0, sizeof(links)); 197 197 ··· 301 301 ieee80211_free_links(sdata, links); 302 302 303 303 return ret; 304 - } 305 - 306 - void ieee80211_vif_clear_links(struct ieee80211_sub_if_data *sdata) 307 - { 308 - struct link_container *links[IEEE80211_MLD_MAX_NUM_LINKS]; 309 - 310 - /* 311 - * The locking here is different because when we free links 312 - * in the station case we need to be able to cancel_work_sync() 313 - * something that also takes the lock. 314 - */ 315 - 316 - sdata_lock(sdata); 317 - ieee80211_vif_update_links(sdata, links, 0, 0); 318 - sdata_unlock(sdata); 319 - 320 - ieee80211_free_links(sdata, links); 321 304 } 322 305 323 306 static int _ieee80211_set_active_links(struct ieee80211_sub_if_data *sdata, ··· 430 447 return 0; 431 448 } 432 449 433 - int __ieee80211_set_active_links(struct ieee80211_vif *vif, u16 active_links) 450 + int ieee80211_set_active_links(struct ieee80211_vif *vif, u16 active_links) 434 451 { 435 452 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 436 453 struct ieee80211_local *local = sdata->local; 437 454 u16 old_active; 438 455 int ret; 439 456 440 - sdata_assert_lock(sdata); 441 457 lockdep_assert_wiphy(local->hw.wiphy); 442 458 443 459 old_active = sdata->vif.active_links; ··· 454 472 /* otherwise switch directly */ 455 473 ret = _ieee80211_set_active_links(sdata, active_links); 456 474 } 457 - 458 - return ret; 459 - } 460 - 461 - int ieee80211_set_active_links(struct ieee80211_vif *vif, u16 active_links) 462 - { 463 - struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 464 - int ret; 465 - 466 - sdata_lock(sdata); 467 - ret = __ieee80211_set_active_links(vif, active_links); 468 - sdata_unlock(sdata); 469 475 470 476 return ret; 471 477 }
+1 -6
net/mac80211/main.c
··· 365 365 */ 366 366 wiphy_work_cancel(local->hw.wiphy, 367 367 &sdata->u.mgd.csa_connection_drop_work); 368 - if (sdata->vif.bss_conf.csa_active) { 369 - sdata_lock(sdata); 368 + if (sdata->vif.bss_conf.csa_active) 370 369 ieee80211_sta_connection_lost(sdata, 371 370 WLAN_REASON_UNSPECIFIED, 372 371 false); 373 - sdata_unlock(sdata); 374 - } 375 372 } 376 373 wiphy_delayed_work_flush(local->hw.wiphy, 377 374 &sdata->dec_tailroom_needed_wk); ··· 470 473 */ 471 474 mutex_lock_nested(&local->hw.wiphy->mtx, 1); 472 475 __acquire(&local->hw.wiphy->mtx); 473 - sdata_lock(sdata); 474 476 475 477 /* Copy the addresses to the vif config list */ 476 478 ifa = rtnl_dereference(idev->ifa_list); ··· 486 490 if (ifmgd->associated) 487 491 ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_ARP_FILTER); 488 492 489 - sdata_unlock(sdata); 490 493 wiphy_unlock(local->hw.wiphy); 491 494 492 495 return NOTIFY_OK;
+6 -10
net/mac80211/mesh.c
··· 1291 1291 ieee80211_conn_flags_t conn_flags = 0; 1292 1292 u32 vht_cap_info = 0; 1293 1293 1294 - sdata_assert_lock(sdata); 1294 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1295 1295 1296 1296 sband = ieee80211_get_sband(sdata); 1297 1297 if (!sband) ··· 1559 1559 struct mesh_csa_settings *tmp_csa_settings; 1560 1560 int ret = 0; 1561 1561 1562 - lockdep_assert_held(&sdata->wdev.mtx); 1562 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1563 1563 1564 1564 tmp_csa_settings = kmalloc(sizeof(*tmp_csa_settings), 1565 1565 GFP_ATOMIC); ··· 1691 1691 struct ieee80211_mgmt *mgmt; 1692 1692 u16 stype; 1693 1693 1694 - sdata_lock(sdata); 1694 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1695 1695 1696 1696 /* mesh already went down */ 1697 1697 if (!sdata->u.mesh.mesh_id_len) 1698 - goto out; 1698 + return; 1699 1699 1700 1700 rx_status = IEEE80211_SKB_RXCB(skb); 1701 1701 mgmt = (struct ieee80211_mgmt *) skb->data; ··· 1714 1714 ieee80211_mesh_rx_mgmt_action(sdata, mgmt, skb->len, rx_status); 1715 1715 break; 1716 1716 } 1717 - out: 1718 - sdata_unlock(sdata); 1719 1717 } 1720 1718 1721 1719 static void mesh_bss_info_changed(struct ieee80211_sub_if_data *sdata) ··· 1743 1745 { 1744 1746 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 1745 1747 1746 - sdata_lock(sdata); 1748 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1747 1749 1748 1750 /* mesh already went down */ 1749 1751 if (!sdata->u.mesh.mesh_id_len) 1750 - goto out; 1752 + return; 1751 1753 1752 1754 if (ifmsh->preq_queue_len && 1753 1755 time_after(jiffies, ··· 1765 1767 1766 1768 if (test_and_clear_bit(MESH_WORK_MBSS_CHANGED, &ifmsh->wrkq_flags)) 1767 1769 mesh_bss_info_changed(sdata); 1768 - out: 1769 - sdata_unlock(sdata); 1770 1770 } 1771 1771 1772 1772
+38 -85
net/mac80211/mlme.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 1 /* 3 2 * BSS client mode implementation 4 3 * Copyright 2003-2008, Jouni Malinen <j@w1.fi> ··· 174 175 static void run_again(struct ieee80211_sub_if_data *sdata, 175 176 unsigned long timeout) 176 177 { 177 - sdata_assert_lock(sdata); 178 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 178 179 179 180 if (!timer_pending(&sdata->u.mgd.timer) || 180 181 time_before(timeout, sdata->u.mgd.timer.expires)) ··· 1400 1401 assoc_data->ie, 1401 1402 assoc_data->ie_len); 1402 1403 1403 - sdata_assert_lock(sdata); 1404 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1404 1405 1405 1406 size = local->hw.extra_tx_headroom + 1406 1407 sizeof(*mgmt) + /* bit too much but doesn't matter */ ··· 1688 1689 if (!ieee80211_sdata_running(sdata)) 1689 1690 return; 1690 1691 1691 - sdata_lock(sdata); 1692 1692 lockdep_assert_wiphy(local->hw.wiphy); 1693 1693 1694 1694 if (!ifmgd->associated) 1695 - goto out; 1695 + return; 1696 1696 1697 1697 if (!link->conf->csa_active) 1698 - goto out; 1698 + return; 1699 1699 1700 1700 /* 1701 1701 * using reservation isn't immediate as it may be deferred until later ··· 1710 1712 * reservations 1711 1713 */ 1712 1714 if (link->reserved_ready) 1713 - goto out; 1715 + return; 1714 1716 1715 1717 ret = ieee80211_link_use_reserved_context(link); 1716 1718 if (ret) { ··· 1719 1721 ret); 1720 1722 wiphy_work_queue(sdata->local->hw.wiphy, 1721 1723 &ifmgd->csa_connection_drop_work); 1722 - goto out; 1723 1724 } 1724 - 1725 - goto out; 1725 + return; 1726 1726 } 1727 1727 1728 1728 if (!cfg80211_chandef_identical(&link->conf->chandef, ··· 1729 1733 "failed to finalize channel switch, disconnecting\n"); 1730 1734 wiphy_work_queue(sdata->local->hw.wiphy, 1731 1735 &ifmgd->csa_connection_drop_work); 1732 - goto out; 1736 + return; 1733 1737 } 1734 1738 1735 1739 link->u.mgd.csa_waiting_bcn = true; 1736 1740 1737 1741 ieee80211_sta_reset_beacon_monitor(sdata); 1738 1742 ieee80211_sta_reset_conn_monitor(sdata); 1739 - 1740 - out: 1741 - sdata_unlock(sdata); 1742 1743 } 1743 1744 1744 1745 static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link) ··· 1745 1752 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1746 1753 int ret; 1747 1754 1748 - sdata_assert_lock(sdata); 1755 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 1749 1756 1750 1757 WARN_ON(!link->conf->csa_active); 1751 1758 ··· 1839 1846 unsigned long timeout; 1840 1847 int res; 1841 1848 1842 - sdata_assert_lock(sdata); 1843 1849 lockdep_assert_wiphy(local->hw.wiphy); 1844 1850 1845 1851 if (!cbss) ··· 2876 2884 .subtype = stype, 2877 2885 }; 2878 2886 2879 - sdata_assert_lock(sdata); 2880 2887 lockdep_assert_wiphy(local->hw.wiphy); 2881 2888 2882 2889 if (WARN_ON_ONCE(tx && !frame_buf)) ··· 3214 3223 if (!ieee80211_sdata_running(sdata)) 3215 3224 return; 3216 3225 3217 - sdata_lock(sdata); 3218 - 3219 3226 if (!ifmgd->associated) 3220 - goto out; 3227 + return; 3221 3228 3222 - if (sdata->local->tmp_channel || sdata->local->scanning) { 3223 - goto out; 3224 - } 3229 + if (sdata->local->tmp_channel || sdata->local->scanning) 3230 + return; 3225 3231 3226 3232 if (sdata->local->suspending) { 3227 3233 /* reschedule after resume */ 3228 3234 ieee80211_reset_ap_probe(sdata); 3229 - goto out; 3235 + return; 3230 3236 } 3231 3237 3232 3238 if (beacon) { ··· 3251 3263 ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL; 3252 3264 3253 3265 if (already) 3254 - goto out; 3266 + return; 3255 3267 3256 3268 ieee80211_recalc_ps(sdata->local); 3257 3269 3258 3270 ifmgd->probe_send_count = 0; 3259 3271 ieee80211_mgd_probe_ap_send(sdata); 3260 - out: 3261 - sdata_unlock(sdata); 3262 3272 } 3263 3273 3264 3274 struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, ··· 3269 3283 const struct element *ssid; 3270 3284 int ssid_len; 3271 3285 3286 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 3287 + 3272 3288 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION || 3273 3289 ieee80211_vif_is_mld(&sdata->vif))) 3274 3290 return NULL; 3275 - 3276 - sdata_assert_lock(sdata); 3277 3291 3278 3292 if (ifmgd->associated) 3279 3293 cbss = sdata->deflink.u.mgd.bss; ··· 3321 3335 drv_event_callback(sdata->local, sdata, &event); 3322 3336 } 3323 3337 3324 - static void ___ieee80211_disconnect(struct ieee80211_sub_if_data *sdata) 3338 + static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata) 3325 3339 { 3326 3340 struct ieee80211_local *local = sdata->local; 3327 3341 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; ··· 3378 3392 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, 3379 3393 ifmgd->reconnect); 3380 3394 ifmgd->reconnect = false; 3381 - } 3382 - 3383 - static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata) 3384 - { 3385 - sdata_lock(sdata); 3386 - ___ieee80211_disconnect(sdata); 3387 - sdata_unlock(sdata); 3388 3395 } 3389 3396 3390 3397 static void ieee80211_beacon_connection_loss_work(struct wiphy *wiphy, ··· 3461 3482 { 3462 3483 struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; 3463 3484 3464 - sdata_assert_lock(sdata); 3465 3485 lockdep_assert_wiphy(sdata->local->hw.wiphy); 3466 3486 3467 3487 if (!assoc) { ··· 3500 3522 { 3501 3523 struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; 3502 3524 3503 - sdata_assert_lock(sdata); 3504 3525 lockdep_assert_wiphy(sdata->local->hw.wiphy); 3505 3526 3506 3527 if (status != ASSOC_SUCCESS) { ··· 3615 3638 .subtype = IEEE80211_STYPE_AUTH, 3616 3639 }; 3617 3640 3618 - sdata_assert_lock(sdata); 3641 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 3619 3642 3620 3643 if (len < 24 + 6) 3621 3644 return; ··· 3773 3796 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3774 3797 u16 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); 3775 3798 3776 - sdata_assert_lock(sdata); 3799 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 3777 3800 3778 3801 if (len < 24 + 2) 3779 3802 return; ··· 3817 3840 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3818 3841 u16 reason_code; 3819 3842 3820 - sdata_assert_lock(sdata); 3843 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 3821 3844 3822 3845 if (len < 24 + 2) 3823 3846 return; ··· 5230 5253 u8 ap_mld_addr[ETH_ALEN] __aligned(2); 5231 5254 unsigned int link_id; 5232 5255 5233 - sdata_assert_lock(sdata); 5256 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 5234 5257 5235 5258 if (!assoc_data) 5236 5259 return; ··· 5430 5453 struct ieee80211_bss *bss; 5431 5454 struct ieee80211_channel *channel; 5432 5455 5433 - sdata_assert_lock(sdata); 5456 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 5434 5457 5435 5458 channel = ieee80211_get_channel_khz(local->hw.wiphy, 5436 5459 ieee80211_rx_status_to_khz(rx_status)); ··· 5457 5480 5458 5481 ifmgd = &sdata->u.mgd; 5459 5482 5460 - sdata_assert_lock(sdata); 5483 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 5461 5484 5462 5485 /* 5463 5486 * According to Draft P802.11ax D6.0 clause 26.17.2.3.2: ··· 5668 5691 u16 new_valid_links, new_active_links, new_dormant_links; 5669 5692 int ret; 5670 5693 5671 - sdata_lock(sdata); 5672 - if (!sdata->u.mgd.removed_links) { 5673 - sdata_unlock(sdata); 5694 + if (!sdata->u.mgd.removed_links) 5674 5695 return; 5675 - } 5676 5696 5677 5697 sdata_info(sdata, 5678 5698 "MLO Reconfiguration: work: valid=0x%x, removed=0x%x\n", 5679 5699 sdata->vif.valid_links, sdata->u.mgd.removed_links); 5680 5700 5681 5701 new_valid_links = sdata->vif.valid_links & ~sdata->u.mgd.removed_links; 5682 - if (new_valid_links == sdata->vif.valid_links) { 5683 - sdata_unlock(sdata); 5702 + if (new_valid_links == sdata->vif.valid_links) 5684 5703 return; 5685 - } 5686 5704 5687 5705 if (!new_valid_links || 5688 5706 !(new_valid_links & ~sdata->vif.dormant_links)) { ··· 5693 5721 BIT(ffs(new_valid_links & 5694 5722 ~sdata->vif.dormant_links) - 1); 5695 5723 5696 - ret = __ieee80211_set_active_links(&sdata->vif, 5697 - new_active_links); 5724 + ret = ieee80211_set_active_links(&sdata->vif, new_active_links); 5698 5725 if (ret) { 5699 5726 sdata_info(sdata, 5700 5727 "Failed setting active links\n"); ··· 5712 5741 if (!ret) 5713 5742 cfg80211_links_removed(sdata->dev, sdata->u.mgd.removed_links); 5714 5743 else 5715 - ___ieee80211_disconnect(sdata); 5744 + __ieee80211_disconnect(sdata); 5716 5745 5717 5746 sdata->u.mgd.removed_links = 0; 5718 - 5719 - sdata_unlock(sdata); 5720 5747 } 5721 5748 5722 5749 static void ieee80211_ml_reconfiguration(struct ieee80211_sub_if_data *sdata, ··· 5842 5873 .from_ap = true, 5843 5874 }; 5844 5875 5845 - sdata_assert_lock(sdata); 5846 5876 lockdep_assert_wiphy(local->hw.wiphy); 5847 5877 5848 5878 /* Process beacon from the current BSS */ ··· 6151 6183 struct ieee80211_hdr *hdr; 6152 6184 u16 fc; 6153 6185 6186 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 6187 + 6154 6188 rx_status = (struct ieee80211_rx_status *) skb->cb; 6155 6189 hdr = (struct ieee80211_hdr *) skb->data; 6156 6190 fc = le16_to_cpu(hdr->frame_control); 6157 6191 6158 - sdata_lock(sdata); 6159 6192 switch (fc & IEEE80211_FCTL_STYPE) { 6160 6193 case IEEE80211_STYPE_S1G_BEACON: 6161 6194 ieee80211_rx_mgmt_beacon(link, hdr, skb->len, rx_status); 6162 6195 break; 6163 6196 } 6164 - sdata_unlock(sdata); 6165 6197 } 6166 6198 6167 6199 void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, ··· 6173 6205 u16 fc; 6174 6206 int ies_len; 6175 6207 6208 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 6209 + 6176 6210 rx_status = (struct ieee80211_rx_status *) skb->cb; 6177 6211 mgmt = (struct ieee80211_mgmt *) skb->data; 6178 6212 fc = le16_to_cpu(mgmt->frame_control); 6179 - 6180 - sdata_lock(sdata); 6181 6213 6182 6214 if (rx_status->link_valid) { 6183 6215 link = sdata_dereference(sdata->link[rx_status->link_id], 6184 6216 sdata); 6185 6217 if (!link) 6186 - goto out; 6218 + return; 6187 6219 } 6188 6220 6189 6221 switch (fc & IEEE80211_FCTL_STYPE) { ··· 6266 6298 } 6267 6299 break; 6268 6300 } 6269 - out: 6270 - sdata_unlock(sdata); 6271 6301 } 6272 6302 6273 6303 static void ieee80211_sta_timer(struct timer_list *t) ··· 6300 6334 .subtype = IEEE80211_STYPE_AUTH, 6301 6335 }; 6302 6336 6303 - sdata_assert_lock(sdata); 6337 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 6304 6338 6305 6339 if (WARN_ON_ONCE(!auth_data)) 6306 6340 return -EINVAL; ··· 6369 6403 struct ieee80211_local *local = sdata->local; 6370 6404 int ret; 6371 6405 6372 - sdata_assert_lock(sdata); 6406 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 6373 6407 6374 6408 assoc_data->tries++; 6375 6409 if (assoc_data->tries > IEEE80211_ASSOC_MAX_TRIES) { ··· 6425 6459 struct ieee80211_local *local = sdata->local; 6426 6460 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 6427 6461 6428 - sdata_lock(sdata); 6462 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 6429 6463 6430 6464 if (ifmgd->status_received) { 6431 6465 __le16 fc = ifmgd->status_fc; ··· 6560 6594 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, false); 6561 6595 } 6562 6596 } 6563 - 6564 - sdata_unlock(sdata); 6565 6597 } 6566 6598 6567 6599 static void ieee80211_sta_bcn_mon_timer(struct timer_list *t) ··· 6646 6682 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 6647 6683 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; 6648 6684 6649 - sdata_lock(sdata); 6685 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 6650 6686 6651 6687 if (ifmgd->auth_data || ifmgd->assoc_data) { 6652 6688 const u8 *ap_addr = ifmgd->auth_data ? ··· 6698 6734 memcpy(bssid, sdata->vif.cfg.ap_addr, ETH_ALEN); 6699 6735 ieee80211_mgd_deauth(sdata, &req); 6700 6736 } 6701 - 6702 - sdata_unlock(sdata); 6703 6737 } 6704 6738 #endif 6705 6739 ··· 6705 6743 { 6706 6744 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 6707 6745 6708 - sdata_lock(sdata); 6709 - if (!ifmgd->associated) { 6710 - sdata_unlock(sdata); 6746 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 6747 + 6748 + if (!ifmgd->associated) 6711 6749 return; 6712 - } 6713 6750 6714 6751 if (sdata->flags & IEEE80211_SDATA_DISCONNECT_RESUME) { 6715 6752 sdata->flags &= ~IEEE80211_SDATA_DISCONNECT_RESUME; ··· 6716 6755 ieee80211_sta_connection_lost(sdata, 6717 6756 WLAN_REASON_UNSPECIFIED, 6718 6757 true); 6719 - sdata_unlock(sdata); 6720 6758 return; 6721 6759 } 6722 6760 ··· 6725 6765 ieee80211_sta_connection_lost(sdata, 6726 6766 WLAN_REASON_UNSPECIFIED, 6727 6767 true); 6728 - sdata_unlock(sdata); 6729 6768 return; 6730 6769 } 6731 - 6732 - sdata_unlock(sdata); 6733 6770 } 6734 6771 6735 6772 static void ieee80211_request_smps_mgd_work(struct wiphy *wiphy, ··· 6736 6779 container_of(work, struct ieee80211_link_data, 6737 6780 u.mgd.request_smps_work); 6738 6781 6739 - sdata_lock(link->sdata); 6740 6782 __ieee80211_request_smps_mgd(link->sdata, link, 6741 6783 link->u.mgd.driver_smps_mode); 6742 - sdata_unlock(link->sdata); 6743 6784 } 6744 6785 6745 6786 /* interface setup */ ··· 7785 7830 wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 7786 7831 &ifmgd->ml_reconf_work); 7787 7832 7788 - sdata_lock(sdata); 7789 7833 if (ifmgd->assoc_data) 7790 7834 ieee80211_destroy_assoc_data(sdata, ASSOC_TIMEOUT); 7791 7835 if (ifmgd->auth_data) ··· 7800 7846 ifmgd->assoc_req_ies_len = 0; 7801 7847 spin_unlock_bh(&ifmgd->teardown_lock); 7802 7848 del_timer_sync(&ifmgd->timer); 7803 - sdata_unlock(sdata); 7804 7849 } 7805 7850 7806 7851 void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
+2 -4
net/mac80211/ocb.c
··· 124 124 struct ieee80211_if_ocb *ifocb = &sdata->u.ocb; 125 125 struct sta_info *sta; 126 126 127 + lockdep_assert_wiphy(sdata->local->hw.wiphy); 128 + 127 129 if (ifocb->joined != true) 128 130 return; 129 - 130 - sdata_lock(sdata); 131 131 132 132 spin_lock_bh(&ifocb->incomplete_lock); 133 133 while (!list_empty(&ifocb->incomplete_stations)) { ··· 144 144 145 145 if (test_and_clear_bit(OCB_WORK_HOUSEKEEPING, &ifocb->wrkq_flags)) 146 146 ieee80211_ocb_housekeeping(sdata); 147 - 148 - sdata_unlock(sdata); 149 147 } 150 148 151 149 static void ieee80211_ocb_housekeeping_timer(struct timer_list *t)
-2
net/mac80211/offchannel.c
··· 826 826 break; 827 827 case NL80211_IFTYPE_STATION: 828 828 case NL80211_IFTYPE_P2P_CLIENT: 829 - sdata_lock(sdata); 830 829 if (!sdata->u.mgd.associated || 831 830 (params->offchan && params->wait && 832 831 local->ops->remain_on_channel && 833 832 memcmp(sdata->vif.cfg.ap_addr, mgmt->bssid, ETH_ALEN))) 834 833 need_offchan = true; 835 - sdata_unlock(sdata); 836 834 break; 837 835 case NL80211_IFTYPE_P2P_DEVICE: 838 836 need_offchan = true;
+10 -16
net/mac80211/tdls.c
··· 1465 1465 /* protect possible bss_conf changes and avoid concurrency in 1466 1466 * ieee80211_bss_info_change_notify() 1467 1467 */ 1468 - sdata_lock(sdata); 1469 1468 tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer); 1470 1469 1471 1470 switch (oper) { 1472 1471 case NL80211_TDLS_ENABLE_LINK: 1473 1472 if (sdata->vif.bss_conf.csa_active) { 1474 1473 tdls_dbg(sdata, "TDLS: disallow link during CSA\n"); 1475 - ret = -EBUSY; 1476 - break; 1474 + return -EBUSY; 1477 1475 } 1478 1476 1479 1477 sta = sta_info_get(sdata, peer); 1480 - if (!sta) { 1481 - ret = -ENOLINK; 1482 - break; 1483 - } 1478 + if (!sta) 1479 + return -ENOLINK; 1484 1480 1485 1481 iee80211_tdls_recalc_chanctx(sdata, sta); 1486 1482 iee80211_tdls_recalc_ht_protection(sdata, sta); ··· 1485 1489 1486 1490 WARN_ON_ONCE(is_zero_ether_addr(sdata->u.mgd.tdls_peer) || 1487 1491 !ether_addr_equal(sdata->u.mgd.tdls_peer, peer)); 1488 - ret = 0; 1489 1492 break; 1490 1493 case NL80211_TDLS_DISABLE_LINK: 1491 1494 /* ··· 1506 1511 iee80211_tdls_recalc_ht_protection(sdata, NULL); 1507 1512 1508 1513 iee80211_tdls_recalc_chanctx(sdata, NULL); 1514 + if (ret) 1515 + return ret; 1509 1516 break; 1510 1517 default: 1511 - ret = -ENOTSUPP; 1512 - break; 1518 + return -ENOTSUPP; 1513 1519 } 1514 1520 1515 - if (ret == 0 && ether_addr_equal(sdata->u.mgd.tdls_peer, peer)) { 1521 + if (ether_addr_equal(sdata->u.mgd.tdls_peer, peer)) { 1516 1522 wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 1517 1523 &sdata->u.mgd.tdls_peer_del_work); 1518 1524 eth_zero_addr(sdata->u.mgd.tdls_peer); 1519 1525 } 1520 1526 1521 - if (ret == 0) 1522 - wiphy_work_queue(sdata->local->hw.wiphy, 1523 - &sdata->deflink.u.mgd.request_smps_work); 1527 + wiphy_work_queue(sdata->local->hw.wiphy, 1528 + &sdata->deflink.u.mgd.request_smps_work); 1524 1529 1525 - sdata_unlock(sdata); 1526 - return ret; 1530 + return 0; 1527 1531 } 1528 1532 1529 1533 void ieee80211_tdls_oper_request(struct ieee80211_vif *vif, const u8 *peer,
-5
net/mac80211/util.c
··· 2664 2664 if (!ieee80211_sdata_running(sdata)) 2665 2665 continue; 2666 2666 2667 - sdata_lock(sdata); 2668 2667 if (ieee80211_vif_is_mld(&sdata->vif)) { 2669 2668 struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS] = { 2670 2669 [0] = &sdata->vif.bss_conf, ··· 2795 2796 case NL80211_IFTYPE_NAN: 2796 2797 res = ieee80211_reconfig_nan(sdata); 2797 2798 if (res < 0) { 2798 - sdata_unlock(sdata); 2799 2799 ieee80211_handle_reconfig_failure(local); 2800 2800 return res; 2801 2801 } ··· 2812 2814 WARN_ON(1); 2813 2815 break; 2814 2816 } 2815 - sdata_unlock(sdata); 2816 2817 2817 2818 if (active_links) 2818 2819 ieee80211_set_active_links(&sdata->vif, active_links); ··· 2841 2844 if (!ieee80211_sdata_running(sdata)) 2842 2845 continue; 2843 2846 2844 - sdata_lock(sdata); 2845 2847 switch (sdata->vif.type) { 2846 2848 case NL80211_IFTYPE_AP_VLAN: 2847 2849 case NL80211_IFTYPE_AP: ··· 2849 2853 default: 2850 2854 break; 2851 2855 } 2852 - sdata_unlock(sdata); 2853 2856 } 2854 2857 2855 2858 /* add back keys */
+5 -19
net/wireless/ap.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 3 * Parts of this file are 4 - * Copyright (C) 2022 Intel Corporation 4 + * Copyright (C) 2022-2023 Intel Corporation 5 5 */ 6 6 #include <linux/ieee80211.h> 7 7 #include <linux/export.h> ··· 18 18 struct wireless_dev *wdev = dev->ieee80211_ptr; 19 19 int err; 20 20 21 - ASSERT_WDEV_LOCK(wdev); 21 + lockdep_assert_wiphy(wdev->wiphy); 22 22 23 23 if (!rdev->ops->stop_ap) 24 24 return -EOPNOTSUPP; ··· 52 52 return err; 53 53 } 54 54 55 - int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 56 - struct net_device *dev, int link_id, 57 - bool notify) 55 + int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 56 + struct net_device *dev, int link_id, 57 + bool notify) 58 58 { 59 59 unsigned int link; 60 60 int ret = 0; ··· 71 71 } 72 72 73 73 return ret; 74 - } 75 - 76 - int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 77 - struct net_device *dev, int link_id, 78 - bool notify) 79 - { 80 - struct wireless_dev *wdev = dev->ieee80211_ptr; 81 - int err; 82 - 83 - wdev_lock(wdev); 84 - err = __cfg80211_stop_ap(rdev, dev, link_id, notify); 85 - wdev_unlock(wdev); 86 - 87 - return err; 88 74 }
+11 -25
net/wireless/chan.c
··· 713 713 { 714 714 unsigned int link; 715 715 716 - ASSERT_WDEV_LOCK(wdev); 716 + lockdep_assert_wiphy(wdev->wiphy); 717 717 718 718 switch (wdev->iftype) { 719 719 case NL80211_IFTYPE_AP: ··· 782 782 { 783 783 struct wireless_dev *wdev; 784 784 785 - list_for_each_entry(wdev, &wiphy->wdev_list, list) { 786 - wdev_lock(wdev); 787 - if (!cfg80211_beaconing_iface_active(wdev)) { 788 - wdev_unlock(wdev); 789 - continue; 790 - } 785 + lockdep_assert_wiphy(wiphy); 791 786 792 - if (cfg80211_wdev_on_sub_chan(wdev, chan, false)) { 793 - wdev_unlock(wdev); 787 + list_for_each_entry(wdev, &wiphy->wdev_list, list) { 788 + if (!cfg80211_beaconing_iface_active(wdev)) 789 + continue; 790 + 791 + if (cfg80211_wdev_on_sub_chan(wdev, chan, false)) 794 792 return true; 795 - } 796 - wdev_unlock(wdev); 797 793 } 798 794 799 795 return false; ··· 1321 1325 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { 1322 1326 bool ret; 1323 1327 1324 - wdev_lock(wdev); 1325 1328 ret = cfg80211_ir_permissive_check_wdev(iftype, wdev, chan); 1326 - wdev_unlock(wdev); 1327 - 1328 1329 if (ret) 1329 1330 return ret; 1330 1331 } ··· 1430 1437 struct cfg80211_chan_def *wdev_chandef(struct wireless_dev *wdev, 1431 1438 unsigned int link_id) 1432 1439 { 1433 - /* 1434 - * We need to sort out the locking here - in some cases 1435 - * where we get here we really just don't care (yet) 1436 - * about the valid links, but in others we do. But we 1437 - * get here with various driver cases, so we cannot 1438 - * easily require the wdev mutex. 1439 - */ 1440 - if (link_id || wdev->valid_links & BIT(0)) { 1441 - ASSERT_WDEV_LOCK(wdev); 1442 - WARN_ON(!(wdev->valid_links & BIT(link_id))); 1443 - } 1440 + lockdep_assert_wiphy(wdev->wiphy); 1441 + 1442 + WARN_ON(wdev->valid_links && !(wdev->valid_links & BIT(link_id))); 1443 + WARN_ON(!wdev->valid_links && link_id > 0); 1444 1444 1445 1445 switch (wdev->iftype) { 1446 1446 case NL80211_IFTYPE_MESH_POINT:
+6 -18
net/wireless/core.c
··· 1278 1278 rdev->num_running_monitor_ifaces += num; 1279 1279 } 1280 1280 1281 - void __cfg80211_leave(struct cfg80211_registered_device *rdev, 1282 - struct wireless_dev *wdev) 1281 + void cfg80211_leave(struct cfg80211_registered_device *rdev, 1282 + struct wireless_dev *wdev) 1283 1283 { 1284 1284 struct net_device *dev = wdev->netdev; 1285 1285 struct cfg80211_sched_scan_request *pos, *tmp; 1286 1286 1287 1287 lockdep_assert_held(&rdev->wiphy.mtx); 1288 - ASSERT_WDEV_LOCK(wdev); 1289 1288 1290 1289 cfg80211_pmsr_wdev_down(wdev); 1291 1290 ··· 1292 1293 1293 1294 switch (wdev->iftype) { 1294 1295 case NL80211_IFTYPE_ADHOC: 1295 - __cfg80211_leave_ibss(rdev, dev, true); 1296 + cfg80211_leave_ibss(rdev, dev, true); 1296 1297 break; 1297 1298 case NL80211_IFTYPE_P2P_CLIENT: 1298 1299 case NL80211_IFTYPE_STATION: ··· 1312 1313 WLAN_REASON_DEAUTH_LEAVING, true); 1313 1314 break; 1314 1315 case NL80211_IFTYPE_MESH_POINT: 1315 - __cfg80211_leave_mesh(rdev, dev); 1316 + cfg80211_leave_mesh(rdev, dev); 1316 1317 break; 1317 1318 case NL80211_IFTYPE_AP: 1318 1319 case NL80211_IFTYPE_P2P_GO: 1319 - __cfg80211_stop_ap(rdev, dev, -1, true); 1320 + cfg80211_stop_ap(rdev, dev, -1, true); 1320 1321 break; 1321 1322 case NL80211_IFTYPE_OCB: 1322 - __cfg80211_leave_ocb(rdev, dev); 1323 + cfg80211_leave_ocb(rdev, dev); 1323 1324 break; 1324 1325 case NL80211_IFTYPE_P2P_DEVICE: 1325 1326 case NL80211_IFTYPE_NAN: ··· 1335 1336 /* invalid */ 1336 1337 break; 1337 1338 } 1338 - } 1339 - 1340 - void cfg80211_leave(struct cfg80211_registered_device *rdev, 1341 - struct wireless_dev *wdev) 1342 - { 1343 - wdev_lock(wdev); 1344 - __cfg80211_leave(rdev, wdev); 1345 - wdev_unlock(wdev); 1346 1339 } 1347 1340 1348 1341 void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev, ··· 1361 1370 1362 1371 void cfg80211_init_wdev(struct wireless_dev *wdev) 1363 1372 { 1364 - mutex_init(&wdev->mtx); 1365 1373 INIT_LIST_HEAD(&wdev->event_list); 1366 1374 spin_lock_init(&wdev->event_lock); 1367 1375 INIT_LIST_HEAD(&wdev->mgmt_registrations); ··· 1523 1533 case NETDEV_UP: 1524 1534 wiphy_lock(&rdev->wiphy); 1525 1535 cfg80211_update_iface_num(rdev, wdev->iftype, 1); 1526 - wdev_lock(wdev); 1527 1536 switch (wdev->iftype) { 1528 1537 #ifdef CONFIG_CFG80211_WEXT 1529 1538 case NL80211_IFTYPE_ADHOC: ··· 1552 1563 default: 1553 1564 break; 1554 1565 } 1555 - wdev_unlock(wdev); 1556 1566 rdev->opencount++; 1557 1567 1558 1568 /*
-36
net/wireless/core.h
··· 235 235 void cfg80211_register_wdev(struct cfg80211_registered_device *rdev, 236 236 struct wireless_dev *wdev); 237 237 238 - static inline void wdev_lock(struct wireless_dev *wdev) 239 - __acquires(wdev) 240 - { 241 - lockdep_assert_held(&wdev->wiphy->mtx); 242 - mutex_lock(&wdev->mtx); 243 - __acquire(wdev->mtx); 244 - } 245 - 246 - static inline void wdev_unlock(struct wireless_dev *wdev) 247 - __releases(wdev) 248 - { 249 - lockdep_assert_held(&wdev->wiphy->mtx); 250 - __release(wdev->mtx); 251 - mutex_unlock(&wdev->mtx); 252 - } 253 - 254 - static inline void ASSERT_WDEV_LOCK(struct wireless_dev *wdev) 255 - { 256 - lockdep_assert_held(&wdev->wiphy->mtx); 257 - lockdep_assert_held(&wdev->mtx); 258 - } 259 - 260 238 static inline bool cfg80211_has_monitors_only(struct cfg80211_registered_device *rdev) 261 239 { 262 240 lockdep_assert_held(&rdev->wiphy.mtx); ··· 318 340 struct cfg80211_ibss_params *params, 319 341 struct cfg80211_cached_keys *connkeys); 320 342 void cfg80211_clear_ibss(struct net_device *dev, bool nowext); 321 - int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, 322 - struct net_device *dev, bool nowext); 323 343 int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, 324 344 struct net_device *dev, bool nowext); 325 345 void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, ··· 332 356 struct net_device *dev, 333 357 struct mesh_setup *setup, 334 358 const struct mesh_config *conf); 335 - int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, 336 - struct net_device *dev); 337 359 int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, 338 360 struct net_device *dev); 339 361 int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, ··· 339 365 struct cfg80211_chan_def *chandef); 340 366 341 367 /* OCB */ 342 - int __cfg80211_join_ocb(struct cfg80211_registered_device *rdev, 343 - struct net_device *dev, 344 - struct ocb_setup *setup); 345 368 int cfg80211_join_ocb(struct cfg80211_registered_device *rdev, 346 369 struct net_device *dev, 347 370 struct ocb_setup *setup); 348 - int __cfg80211_leave_ocb(struct cfg80211_registered_device *rdev, 349 - struct net_device *dev); 350 371 int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev, 351 372 struct net_device *dev); 352 373 353 374 /* AP */ 354 - int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 355 - struct net_device *dev, int link, 356 - bool notify); 357 375 int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 358 376 struct net_device *dev, int link, 359 377 bool notify); ··· 523 557 void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, 524 558 enum nl80211_iftype iftype, int num); 525 559 526 - void __cfg80211_leave(struct cfg80211_registered_device *rdev, 527 - struct wireless_dev *wdev); 528 560 void cfg80211_leave(struct cfg80211_registered_device *rdev, 529 561 struct wireless_dev *wdev); 530 562
+14 -62
net/wireless/ibss.c
··· 3 3 * Some IBSS support code for cfg80211. 4 4 * 5 5 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> 6 - * Copyright (C) 2020-2022 Intel Corporation 6 + * Copyright (C) 2020-2023 Intel Corporation 7 7 */ 8 8 9 9 #include <linux/etherdevice.h> ··· 93 93 int err; 94 94 95 95 lockdep_assert_held(&rdev->wiphy.mtx); 96 - ASSERT_WDEV_LOCK(wdev); 97 96 98 97 if (wdev->u.ibss.ssid_len) 99 98 return -EALREADY; ··· 150 151 return 0; 151 152 } 152 153 153 - static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext) 154 + void cfg80211_clear_ibss(struct net_device *dev, bool nowext) 154 155 { 155 156 struct wireless_dev *wdev = dev->ieee80211_ptr; 156 157 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 157 158 int i; 158 159 159 - ASSERT_WDEV_LOCK(wdev); 160 + lockdep_assert_wiphy(wdev->wiphy); 160 161 161 162 kfree_sensitive(wdev->connect_keys); 162 163 wdev->connect_keys = NULL; ··· 186 187 cfg80211_sched_dfs_chan_update(rdev); 187 188 } 188 189 189 - void cfg80211_clear_ibss(struct net_device *dev, bool nowext) 190 - { 191 - struct wireless_dev *wdev = dev->ieee80211_ptr; 192 - 193 - wdev_lock(wdev); 194 - __cfg80211_clear_ibss(dev, nowext); 195 - wdev_unlock(wdev); 196 - } 197 - 198 - int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, 199 - struct net_device *dev, bool nowext) 190 + int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, 191 + struct net_device *dev, bool nowext) 200 192 { 201 193 struct wireless_dev *wdev = dev->ieee80211_ptr; 202 194 int err; 203 195 204 - ASSERT_WDEV_LOCK(wdev); 196 + lockdep_assert_wiphy(wdev->wiphy); 205 197 206 198 if (!wdev->u.ibss.ssid_len) 207 199 return -ENOLINK; ··· 203 213 return err; 204 214 205 215 wdev->conn_owner_nlportid = 0; 206 - __cfg80211_clear_ibss(dev, nowext); 216 + cfg80211_clear_ibss(dev, nowext); 207 217 208 218 return 0; 209 - } 210 - 211 - int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, 212 - struct net_device *dev, bool nowext) 213 - { 214 - struct wireless_dev *wdev = dev->ieee80211_ptr; 215 - int err; 216 - 217 - wdev_lock(wdev); 218 - err = __cfg80211_leave_ibss(rdev, dev, nowext); 219 - wdev_unlock(wdev); 220 - 221 - return err; 222 219 } 223 220 224 221 #ifdef CONFIG_CFG80211_WEXT ··· 216 239 enum nl80211_band band; 217 240 int i, err; 218 241 219 - ASSERT_WDEV_LOCK(wdev); 242 + lockdep_assert_wiphy(wdev->wiphy); 220 243 221 244 if (!wdev->wext.ibss.beacon_interval) 222 245 wdev->wext.ibss.beacon_interval = 100; ··· 313 336 if (wdev->wext.ibss.chandef.chan == chan) 314 337 return 0; 315 338 316 - wdev_lock(wdev); 317 339 err = 0; 318 340 if (wdev->u.ibss.ssid_len) 319 - err = __cfg80211_leave_ibss(rdev, dev, true); 320 - wdev_unlock(wdev); 341 + err = cfg80211_leave_ibss(rdev, dev, true); 321 342 322 343 if (err) 323 344 return err; ··· 329 354 wdev->wext.ibss.channel_fixed = false; 330 355 } 331 356 332 - wdev_lock(wdev); 333 - err = cfg80211_ibss_wext_join(rdev, wdev); 334 - wdev_unlock(wdev); 335 - 336 - return err; 357 + return cfg80211_ibss_wext_join(rdev, wdev); 337 358 } 338 359 339 360 int cfg80211_ibss_wext_giwfreq(struct net_device *dev, ··· 343 372 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_ADHOC)) 344 373 return -EINVAL; 345 374 346 - wdev_lock(wdev); 347 375 if (wdev->u.ibss.current_bss) 348 376 chan = wdev->u.ibss.current_bss->pub.channel; 349 377 else if (wdev->wext.ibss.chandef.chan) 350 378 chan = wdev->wext.ibss.chandef.chan; 351 - wdev_unlock(wdev); 352 379 353 380 if (chan) { 354 381 freq->m = chan->center_freq; ··· 374 405 if (!rdev->ops->join_ibss) 375 406 return -EOPNOTSUPP; 376 407 377 - wdev_lock(wdev); 378 408 err = 0; 379 409 if (wdev->u.ibss.ssid_len) 380 - err = __cfg80211_leave_ibss(rdev, dev, true); 381 - wdev_unlock(wdev); 410 + err = cfg80211_leave_ibss(rdev, dev, true); 382 411 383 412 if (err) 384 413 return err; ··· 389 422 wdev->wext.ibss.ssid = wdev->u.ibss.ssid; 390 423 wdev->wext.ibss.ssid_len = len; 391 424 392 - wdev_lock(wdev); 393 - err = cfg80211_ibss_wext_join(rdev, wdev); 394 - wdev_unlock(wdev); 395 - 396 - return err; 425 + return cfg80211_ibss_wext_join(rdev, wdev); 397 426 } 398 427 399 428 int cfg80211_ibss_wext_giwessid(struct net_device *dev, ··· 404 441 405 442 data->flags = 0; 406 443 407 - wdev_lock(wdev); 408 444 if (wdev->u.ibss.ssid_len) { 409 445 data->flags = 1; 410 446 data->length = wdev->u.ibss.ssid_len; ··· 413 451 data->length = wdev->wext.ibss.ssid_len; 414 452 memcpy(ssid, wdev->wext.ibss.ssid, data->length); 415 453 } 416 - wdev_unlock(wdev); 417 454 418 455 return 0; 419 456 } ··· 452 491 ether_addr_equal(bssid, wdev->wext.ibss.bssid)) 453 492 return 0; 454 493 455 - wdev_lock(wdev); 456 494 err = 0; 457 495 if (wdev->u.ibss.ssid_len) 458 - err = __cfg80211_leave_ibss(rdev, dev, true); 459 - wdev_unlock(wdev); 496 + err = cfg80211_leave_ibss(rdev, dev, true); 460 497 461 498 if (err) 462 499 return err; ··· 465 506 } else 466 507 wdev->wext.ibss.bssid = NULL; 467 508 468 - wdev_lock(wdev); 469 - err = cfg80211_ibss_wext_join(rdev, wdev); 470 - wdev_unlock(wdev); 471 - 472 - return err; 509 + return cfg80211_ibss_wext_join(rdev, wdev); 473 510 } 474 511 475 512 int cfg80211_ibss_wext_giwap(struct net_device *dev, ··· 480 525 481 526 ap_addr->sa_family = ARPHRD_ETHER; 482 527 483 - wdev_lock(wdev); 484 528 if (wdev->u.ibss.current_bss) 485 529 memcpy(ap_addr->sa_data, wdev->u.ibss.current_bss->pub.bssid, 486 530 ETH_ALEN); ··· 487 533 memcpy(ap_addr->sa_data, wdev->wext.ibss.bssid, ETH_ALEN); 488 534 else 489 535 eth_zero_addr(ap_addr->sa_data); 490 - 491 - wdev_unlock(wdev); 492 536 493 537 return 0; 494 538 }
+5 -18
net/wireless/mesh.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 3 * Portions 4 - * Copyright (C) 2022 Intel Corporation 4 + * Copyright (C) 2022-2023 Intel Corporation 5 5 */ 6 6 #include <linux/ieee80211.h> 7 7 #include <linux/export.h> ··· 109 109 110 110 BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN != IEEE80211_MAX_MESH_ID_LEN); 111 111 112 - ASSERT_WDEV_LOCK(wdev); 112 + lockdep_assert_wiphy(wdev->wiphy); 113 113 114 114 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) 115 115 return -EOPNOTSUPP; ··· 257 257 return 0; 258 258 } 259 259 260 - int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, 261 - struct net_device *dev) 260 + int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, 261 + struct net_device *dev) 262 262 { 263 263 struct wireless_dev *wdev = dev->ieee80211_ptr; 264 264 int err; 265 265 266 - ASSERT_WDEV_LOCK(wdev); 266 + lockdep_assert_wiphy(wdev->wiphy); 267 267 268 268 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) 269 269 return -EOPNOTSUPP; ··· 284 284 rdev_set_qos_map(rdev, dev, NULL); 285 285 cfg80211_sched_dfs_chan_update(rdev); 286 286 } 287 - 288 - return err; 289 - } 290 - 291 - int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, 292 - struct net_device *dev) 293 - { 294 - struct wireless_dev *wdev = dev->ieee80211_ptr; 295 - int err; 296 - 297 - wdev_lock(wdev); 298 - err = __cfg80211_leave_mesh(rdev, dev); 299 - wdev_unlock(wdev); 300 287 301 288 return err; 302 289 }
+10 -11
net/wireless/mlme.c
··· 4 4 * 5 5 * Copyright (c) 2009, Jouni Malinen <j@w1.fi> 6 6 * Copyright (c) 2015 Intel Deutschland GmbH 7 - * Copyright (C) 2019-2020, 2022 Intel Corporation 7 + * Copyright (C) 2019-2020, 2022-2023 Intel Corporation 8 8 */ 9 9 10 10 #include <linux/kernel.h> ··· 149 149 struct wireless_dev *wdev = dev->ieee80211_ptr; 150 150 struct ieee80211_mgmt *mgmt = (void *)buf; 151 151 152 - ASSERT_WDEV_LOCK(wdev); 152 + lockdep_assert_wiphy(wdev->wiphy); 153 153 154 154 trace_cfg80211_rx_mlme_mgmt(dev, buf, len); 155 155 ··· 214 214 struct wireless_dev *wdev = dev->ieee80211_ptr; 215 215 struct ieee80211_mgmt *mgmt = (void *)buf; 216 216 217 - ASSERT_WDEV_LOCK(wdev); 217 + lockdep_assert_wiphy(wdev->wiphy); 218 218 219 219 trace_cfg80211_tx_mlme_mgmt(dev, buf, len, reconnect); 220 220 ··· 262 262 { 263 263 struct wireless_dev *wdev = dev->ieee80211_ptr; 264 264 265 - ASSERT_WDEV_LOCK(wdev); 265 + lockdep_assert_wiphy(wdev->wiphy); 266 266 267 267 if (!req->bss) 268 268 return -ENOENT; ··· 331 331 struct wireless_dev *wdev = dev->ieee80211_ptr; 332 332 int err, i, j; 333 333 334 - ASSERT_WDEV_LOCK(wdev); 334 + lockdep_assert_wiphy(wdev->wiphy); 335 335 336 336 for (i = 1; i < ARRAY_SIZE(req->links); i++) { 337 337 if (!req->links[i].bss) ··· 393 393 .local_state_change = local_state_change, 394 394 }; 395 395 396 - ASSERT_WDEV_LOCK(wdev); 396 + lockdep_assert_wiphy(wdev->wiphy); 397 397 398 398 if (local_state_change && 399 399 (!wdev->connected || ··· 423 423 }; 424 424 int err; 425 425 426 - ASSERT_WDEV_LOCK(wdev); 426 + lockdep_assert_wiphy(wdev->wiphy); 427 427 428 428 if (!wdev->connected) 429 429 return -ENOTCONN; ··· 446 446 struct wireless_dev *wdev = dev->ieee80211_ptr; 447 447 u8 bssid[ETH_ALEN]; 448 448 449 - ASSERT_WDEV_LOCK(wdev); 449 + lockdep_assert_wiphy(wdev->wiphy); 450 450 451 451 if (!rdev->ops->deauth) 452 452 return; ··· 726 726 const struct ieee80211_mgmt *mgmt; 727 727 u16 stype; 728 728 729 + lockdep_assert_wiphy(&rdev->wiphy); 730 + 729 731 if (!wdev->wiphy->mgmt_stypes) 730 732 return -EOPNOTSUPP; 731 733 ··· 749 747 if (ieee80211_is_action(mgmt->frame_control) && 750 748 mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) { 751 749 int err = 0; 752 - 753 - wdev_lock(wdev); 754 750 755 751 switch (wdev->iftype) { 756 752 case NL80211_IFTYPE_ADHOC: ··· 814 814 err = -EOPNOTSUPP; 815 815 break; 816 816 } 817 - wdev_unlock(wdev); 818 817 819 818 if (err) 820 819 return err;
+97 -301
net/wireless/nl80211.c
··· 1544 1544 1545 1545 static int nl80211_key_allowed(struct wireless_dev *wdev) 1546 1546 { 1547 - ASSERT_WDEV_LOCK(wdev); 1547 + lockdep_assert_wiphy(wdev->wiphy); 1548 1548 1549 1549 switch (wdev->iftype) { 1550 1550 case NL80211_IFTYPE_AP: ··· 3423 3423 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 3424 3424 int link_id = nl80211_link_id_or_invalid(info->attrs); 3425 3425 struct net_device *netdev = info->user_ptr[1]; 3426 - int ret; 3427 3426 3428 - wdev_lock(netdev->ieee80211_ptr); 3429 - ret = __nl80211_set_channel(rdev, netdev, info, link_id); 3430 - wdev_unlock(netdev->ieee80211_ptr); 3431 - 3432 - return ret; 3427 + return __nl80211_set_channel(rdev, netdev, info, link_id); 3433 3428 } 3434 3429 3435 3430 static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) ··· 3531 3536 txq_params.link_id = 3532 3537 nl80211_link_id_or_invalid(info->attrs); 3533 3538 3534 - wdev_lock(netdev->ieee80211_ptr); 3535 3539 if (txq_params.link_id >= 0 && 3536 3540 !(netdev->ieee80211_ptr->valid_links & 3537 3541 BIT(txq_params.link_id))) ··· 3541 3547 else 3542 3548 result = rdev_set_txq_params(rdev, netdev, 3543 3549 &txq_params); 3544 - wdev_unlock(netdev->ieee80211_ptr); 3545 3550 if (result) 3546 3551 goto out; 3547 3552 } ··· 3550 3557 int link_id = nl80211_link_id_or_invalid(info->attrs); 3551 3558 3552 3559 if (wdev) { 3553 - wdev_lock(wdev); 3554 3560 result = __nl80211_set_channel( 3555 3561 rdev, 3556 3562 nl80211_can_set_dev_channel(wdev) ? netdev : NULL, 3557 3563 info, link_id); 3558 - wdev_unlock(wdev); 3559 3564 } else { 3560 3565 result = __nl80211_set_channel(rdev, netdev, info, link_id); 3561 3566 } ··· 3861 3870 goto nla_put_failure; 3862 3871 } 3863 3872 3864 - wdev_lock(wdev); 3865 3873 switch (wdev->iftype) { 3866 3874 case NL80211_IFTYPE_AP: 3867 3875 case NL80211_IFTYPE_P2P_GO: 3868 3876 if (wdev->u.ap.ssid_len && 3869 3877 nla_put(msg, NL80211_ATTR_SSID, wdev->u.ap.ssid_len, 3870 3878 wdev->u.ap.ssid)) 3871 - goto nla_put_failure_locked; 3879 + goto nla_put_failure; 3872 3880 break; 3873 3881 case NL80211_IFTYPE_STATION: 3874 3882 case NL80211_IFTYPE_P2P_CLIENT: 3875 3883 if (wdev->u.client.ssid_len && 3876 3884 nla_put(msg, NL80211_ATTR_SSID, wdev->u.client.ssid_len, 3877 3885 wdev->u.client.ssid)) 3878 - goto nla_put_failure_locked; 3886 + goto nla_put_failure; 3879 3887 break; 3880 3888 case NL80211_IFTYPE_ADHOC: 3881 3889 if (wdev->u.ibss.ssid_len && 3882 3890 nla_put(msg, NL80211_ATTR_SSID, wdev->u.ibss.ssid_len, 3883 3891 wdev->u.ibss.ssid)) 3884 - goto nla_put_failure_locked; 3892 + goto nla_put_failure; 3885 3893 break; 3886 3894 default: 3887 3895 /* nothing */ 3888 3896 break; 3889 3897 } 3890 - wdev_unlock(wdev); 3891 3898 3892 3899 if (rdev->ops->get_txq_stats) { 3893 3900 struct cfg80211_txq_stats txqstats = {}; ··· 3932 3943 genlmsg_end(msg, hdr); 3933 3944 return 0; 3934 3945 3935 - nla_put_failure_locked: 3936 - wdev_unlock(wdev); 3937 3946 nla_put_failure: 3938 3947 genlmsg_cancel(msg, hdr); 3939 3948 return -EMSGSIZE; ··· 4178 4191 if (netif_running(dev)) 4179 4192 return -EBUSY; 4180 4193 4181 - wdev_lock(wdev); 4182 4194 BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN != 4183 4195 IEEE80211_MAX_MESH_ID_LEN); 4184 4196 wdev->u.mesh.id_up_len = ··· 4185 4199 memcpy(wdev->u.mesh.id, 4186 4200 nla_data(info->attrs[NL80211_ATTR_MESH_ID]), 4187 4201 wdev->u.mesh.id_up_len); 4188 - wdev_unlock(wdev); 4189 4202 } 4190 4203 4191 4204 if (info->attrs[NL80211_ATTR_4ADDR]) { ··· 4285 4300 case NL80211_IFTYPE_MESH_POINT: 4286 4301 if (!info->attrs[NL80211_ATTR_MESH_ID]) 4287 4302 break; 4288 - wdev_lock(wdev); 4289 4303 BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN != 4290 4304 IEEE80211_MAX_MESH_ID_LEN); 4291 4305 wdev->u.mesh.id_up_len = ··· 4292 4308 memcpy(wdev->u.mesh.id, 4293 4309 nla_data(info->attrs[NL80211_ATTR_MESH_ID]), 4294 4310 wdev->u.mesh.id_up_len); 4295 - wdev_unlock(wdev); 4296 4311 break; 4297 4312 case NL80211_IFTYPE_NAN: 4298 4313 case NL80211_IFTYPE_P2P_DEVICE: ··· 4582 4599 !(key.p.mode == NL80211_KEY_SET_TX)) 4583 4600 return -EINVAL; 4584 4601 4585 - wdev_lock(wdev); 4586 - 4587 4602 if (key.def) { 4588 - if (!rdev->ops->set_default_key) { 4589 - err = -EOPNOTSUPP; 4590 - goto out; 4591 - } 4603 + if (!rdev->ops->set_default_key) 4604 + return -EOPNOTSUPP; 4592 4605 4593 4606 err = nl80211_key_allowed(wdev); 4594 4607 if (err) 4595 - goto out; 4608 + return err; 4596 4609 4597 4610 err = nl80211_validate_key_link_id(info, wdev, link_id, false); 4598 4611 if (err) 4599 - goto out; 4612 + return err; 4600 4613 4601 4614 err = rdev_set_default_key(rdev, dev, link_id, key.idx, 4602 4615 key.def_uni, key.def_multi); 4603 4616 4604 4617 if (err) 4605 - goto out; 4618 + return err; 4606 4619 4607 4620 #ifdef CONFIG_CFG80211_WEXT 4608 4621 wdev->wext.default_key = key.idx; 4609 4622 #endif 4623 + return 0; 4610 4624 } else if (key.defmgmt) { 4611 - if (key.def_uni || !key.def_multi) { 4612 - err = -EINVAL; 4613 - goto out; 4614 - } 4625 + if (key.def_uni || !key.def_multi) 4626 + return -EINVAL; 4615 4627 4616 - if (!rdev->ops->set_default_mgmt_key) { 4617 - err = -EOPNOTSUPP; 4618 - goto out; 4619 - } 4628 + if (!rdev->ops->set_default_mgmt_key) 4629 + return -EOPNOTSUPP; 4620 4630 4621 4631 err = nl80211_key_allowed(wdev); 4622 4632 if (err) 4623 - goto out; 4633 + return err; 4624 4634 4625 4635 err = nl80211_validate_key_link_id(info, wdev, link_id, false); 4626 4636 if (err) 4627 - goto out; 4637 + return err; 4628 4638 4629 4639 err = rdev_set_default_mgmt_key(rdev, dev, link_id, key.idx); 4630 4640 if (err) 4631 - goto out; 4641 + return err; 4632 4642 4633 4643 #ifdef CONFIG_CFG80211_WEXT 4634 4644 wdev->wext.default_mgmt_key = key.idx; 4635 4645 #endif 4646 + return 0; 4636 4647 } else if (key.defbeacon) { 4637 - if (key.def_uni || !key.def_multi) { 4638 - err = -EINVAL; 4639 - goto out; 4640 - } 4648 + if (key.def_uni || !key.def_multi) 4649 + return -EINVAL; 4641 4650 4642 - if (!rdev->ops->set_default_beacon_key) { 4643 - err = -EOPNOTSUPP; 4644 - goto out; 4645 - } 4651 + if (!rdev->ops->set_default_beacon_key) 4652 + return -EOPNOTSUPP; 4646 4653 4647 4654 err = nl80211_key_allowed(wdev); 4648 4655 if (err) 4649 - goto out; 4656 + return err; 4650 4657 4651 4658 err = nl80211_validate_key_link_id(info, wdev, link_id, false); 4652 4659 if (err) 4653 - goto out; 4660 + return err; 4654 4661 4655 - err = rdev_set_default_beacon_key(rdev, dev, link_id, key.idx); 4656 - if (err) 4657 - goto out; 4662 + return rdev_set_default_beacon_key(rdev, dev, link_id, key.idx); 4658 4663 } else if (key.p.mode == NL80211_KEY_SET_TX && 4659 4664 wiphy_ext_feature_isset(&rdev->wiphy, 4660 4665 NL80211_EXT_FEATURE_EXT_KEY_ID)) { ··· 4651 4680 if (info->attrs[NL80211_ATTR_MAC]) 4652 4681 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 4653 4682 4654 - if (!mac_addr || key.idx < 0 || key.idx > 1) { 4655 - err = -EINVAL; 4656 - goto out; 4657 - } 4683 + if (!mac_addr || key.idx < 0 || key.idx > 1) 4684 + return -EINVAL; 4658 4685 4659 4686 err = nl80211_validate_key_link_id(info, wdev, link_id, true); 4660 4687 if (err) 4661 - goto out; 4688 + return err; 4662 4689 4663 - err = rdev_add_key(rdev, dev, link_id, key.idx, 4664 - NL80211_KEYTYPE_PAIRWISE, 4665 - mac_addr, &key.p); 4666 - } else { 4667 - err = -EINVAL; 4690 + return rdev_add_key(rdev, dev, link_id, key.idx, 4691 + NL80211_KEYTYPE_PAIRWISE, 4692 + mac_addr, &key.p); 4668 4693 } 4669 - out: 4670 - wdev_unlock(wdev); 4671 4694 4672 - return err; 4695 + return -EINVAL; 4673 4696 } 4674 4697 4675 4698 static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) ··· 4716 4751 return -EINVAL; 4717 4752 } 4718 4753 4719 - wdev_lock(wdev); 4720 4754 err = nl80211_key_allowed(wdev); 4721 4755 if (err) 4722 4756 GENL_SET_ERR_MSG(info, "key not allowed"); ··· 4731 4767 if (err) 4732 4768 GENL_SET_ERR_MSG(info, "key addition failed"); 4733 4769 } 4734 - wdev_unlock(wdev); 4735 4770 4736 4771 return err; 4737 4772 } ··· 4771 4808 if (!rdev->ops->del_key) 4772 4809 return -EOPNOTSUPP; 4773 4810 4774 - wdev_lock(wdev); 4775 4811 err = nl80211_key_allowed(wdev); 4776 4812 4777 4813 if (key.type == NL80211_KEYTYPE_GROUP && mac_addr && ··· 4794 4832 wdev->wext.default_mgmt_key = -1; 4795 4833 } 4796 4834 #endif 4797 - wdev_unlock(wdev); 4798 4835 4799 4836 return err; 4800 4837 } ··· 6033 6072 goto out; 6034 6073 } 6035 6074 6036 - wdev_lock(wdev); 6037 - 6038 6075 if (info->attrs[NL80211_ATTR_TX_RATES]) { 6039 6076 err = nl80211_parse_tx_bitrate_mask(info, info->attrs, 6040 6077 NL80211_ATTR_TX_RATES, 6041 6078 &params->beacon_rate, 6042 6079 dev, false, link_id); 6043 6080 if (err) 6044 - goto out_unlock; 6081 + goto out; 6045 6082 6046 6083 err = validate_beacon_tx_rate(rdev, params->chandef.chan->band, 6047 6084 &params->beacon_rate); 6048 6085 if (err) 6049 - goto out_unlock; 6086 + goto out; 6050 6087 } 6051 6088 6052 6089 if (info->attrs[NL80211_ATTR_SMPS_MODE]) { ··· 6057 6098 if (!(rdev->wiphy.features & 6058 6099 NL80211_FEATURE_STATIC_SMPS)) { 6059 6100 err = -EINVAL; 6060 - goto out_unlock; 6101 + goto out; 6061 6102 } 6062 6103 break; 6063 6104 case NL80211_SMPS_DYNAMIC: 6064 6105 if (!(rdev->wiphy.features & 6065 6106 NL80211_FEATURE_DYNAMIC_SMPS)) { 6066 6107 err = -EINVAL; 6067 - goto out_unlock; 6108 + goto out; 6068 6109 } 6069 6110 break; 6070 6111 default: 6071 6112 err = -EINVAL; 6072 - goto out_unlock; 6113 + goto out; 6073 6114 } 6074 6115 } else { 6075 6116 params->smps_mode = NL80211_SMPS_OFF; ··· 6078 6119 params->pbss = nla_get_flag(info->attrs[NL80211_ATTR_PBSS]); 6079 6120 if (params->pbss && !rdev->wiphy.bands[NL80211_BAND_60GHZ]) { 6080 6121 err = -EOPNOTSUPP; 6081 - goto out_unlock; 6122 + goto out; 6082 6123 } 6083 6124 6084 6125 if (info->attrs[NL80211_ATTR_ACL_POLICY]) { ··· 6086 6127 if (IS_ERR(params->acl)) { 6087 6128 err = PTR_ERR(params->acl); 6088 6129 params->acl = NULL; 6089 - goto out_unlock; 6130 + goto out; 6090 6131 } 6091 6132 } 6092 6133 ··· 6098 6139 info->attrs[NL80211_ATTR_HE_OBSS_PD], 6099 6140 &params->he_obss_pd); 6100 6141 if (err) 6101 - goto out_unlock; 6142 + goto out; 6102 6143 } 6103 6144 6104 6145 if (info->attrs[NL80211_ATTR_FILS_DISCOVERY]) { ··· 6106 6147 info->attrs[NL80211_ATTR_FILS_DISCOVERY], 6107 6148 params); 6108 6149 if (err) 6109 - goto out_unlock; 6150 + goto out; 6110 6151 } 6111 6152 6112 6153 if (info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP]) { ··· 6114 6155 rdev, info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP], 6115 6156 params); 6116 6157 if (err) 6117 - goto out_unlock; 6158 + goto out; 6118 6159 } 6119 6160 6120 6161 if (info->attrs[NL80211_ATTR_MBSSID_CONFIG]) { ··· 6125 6166 params->beacon.mbssid_ies->cnt : 6126 6167 0); 6127 6168 if (err) 6128 - goto out_unlock; 6169 + goto out; 6129 6170 } 6130 6171 6131 6172 if (!params->mbssid_config.ema && params->beacon.rnr_ies) { 6132 6173 err = -EINVAL; 6133 - goto out_unlock; 6174 + goto out; 6134 6175 } 6135 6176 6136 6177 err = nl80211_calculate_ap_params(params); 6137 6178 if (err) 6138 - goto out_unlock; 6179 + goto out; 6139 6180 6140 6181 if (info->attrs[NL80211_ATTR_AP_SETTINGS_FLAGS]) 6141 6182 params->flags = nla_get_u32( ··· 6147 6188 info->attrs[NL80211_ATTR_SOCKET_OWNER] && 6148 6189 wdev->conn_owner_nlportid != info->snd_portid) { 6149 6190 err = -EINVAL; 6150 - goto out_unlock; 6191 + goto out; 6151 6192 } 6152 6193 6153 6194 /* FIXME: validate MLO/link-id against driver capabilities */ ··· 6165 6206 6166 6207 nl80211_send_ap_started(wdev, link_id); 6167 6208 } 6168 - out_unlock: 6169 - wdev_unlock(wdev); 6170 6209 out: 6171 6210 kfree(params->acl); 6172 6211 kfree(params->beacon.mbssid_ies); ··· 6201 6244 if (err) 6202 6245 goto out; 6203 6246 6204 - wdev_lock(wdev); 6205 6247 err = rdev_change_beacon(rdev, dev, &params); 6206 - wdev_unlock(wdev); 6207 6248 6208 6249 out: 6209 6250 kfree(params.mbssid_ies); ··· 7260 7305 } 7261 7306 7262 7307 /* driver will call cfg80211_check_station_change() */ 7263 - wdev_lock(dev->ieee80211_ptr); 7264 7308 err = rdev_change_station(rdev, dev, mac_addr, &params); 7265 - wdev_unlock(dev->ieee80211_ptr); 7266 7309 7267 7310 out_put_vlan: 7268 7311 dev_put(params.vlan); ··· 7528 7575 7529 7576 /* be aware of params.vlan when changing code here */ 7530 7577 7531 - wdev_lock(dev->ieee80211_ptr); 7532 7578 if (wdev->valid_links) { 7533 7579 if (params.link_sta_params.link_id < 0) { 7534 7580 err = -EINVAL; ··· 7545 7593 } 7546 7594 err = rdev_add_station(rdev, dev, mac_addr, &params); 7547 7595 out: 7548 - wdev_unlock(dev->ieee80211_ptr); 7549 7596 dev_put(params.vlan); 7550 7597 return err; 7551 7598 } ··· 7554 7603 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 7555 7604 struct net_device *dev = info->user_ptr[1]; 7556 7605 struct station_del_parameters params; 7557 - int ret; 7558 7606 7559 7607 memset(&params, 0, sizeof(params)); 7560 7608 ··· 7601 7651 params.reason_code = WLAN_REASON_PREV_AUTH_NOT_VALID; 7602 7652 } 7603 7653 7604 - wdev_lock(dev->ieee80211_ptr); 7605 - ret = rdev_del_station(rdev, dev, &params); 7606 - wdev_unlock(dev->ieee80211_ptr); 7607 - 7608 - return ret; 7654 + return rdev_del_station(rdev, dev, &params); 7609 7655 } 7610 7656 7611 7657 static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq, ··· 7920 7974 { 7921 7975 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 7922 7976 struct net_device *dev = info->user_ptr[1]; 7923 - struct wireless_dev *wdev = dev->ieee80211_ptr; 7924 7977 struct bss_parameters params; 7925 - int err; 7926 7978 7927 7979 memset(&params, 0, sizeof(params)); 7928 7980 params.link_id = nl80211_link_id_or_invalid(info->attrs); ··· 7983 8039 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) 7984 8040 return -EOPNOTSUPP; 7985 8041 7986 - wdev_lock(wdev); 7987 - err = rdev_change_bss(rdev, dev, &params); 7988 - wdev_unlock(wdev); 7989 - 7990 - return err; 8042 + return rdev_change_bss(rdev, dev, &params); 7991 8043 } 7992 8044 7993 8045 static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) ··· 8054 8114 if (!rdev->ops->get_mesh_config) 8055 8115 return -EOPNOTSUPP; 8056 8116 8057 - wdev_lock(wdev); 8058 8117 /* If not connected, get default parameters */ 8059 8118 if (!wdev->u.mesh.id_len) 8060 8119 memcpy(&cur_params, &default_mesh_config, sizeof(cur_params)); 8061 8120 else 8062 8121 err = rdev_get_mesh_config(rdev, dev, &cur_params); 8063 - wdev_unlock(wdev); 8064 8122 8065 8123 if (err) 8066 8124 return err; ··· 8434 8496 if (err) 8435 8497 return err; 8436 8498 8437 - wdev_lock(wdev); 8438 8499 if (!wdev->u.mesh.id_len) 8439 8500 err = -ENOLINK; 8440 8501 8441 8502 if (!err) 8442 8503 err = rdev_update_mesh_config(rdev, dev, mask, &cfg); 8443 - 8444 - wdev_unlock(wdev); 8445 8504 8446 8505 return err; 8447 8506 } ··· 8930 8995 unsigned int link_id; 8931 8996 bool all_ok = true; 8932 8997 8933 - ASSERT_WDEV_LOCK(wdev); 8998 + lockdep_assert_wiphy(wdev->wiphy); 8934 8999 8935 9000 if (!cfg80211_beaconing_iface_active(wdev)) 8936 9001 return true; ··· 9180 9245 9181 9246 request->n_channels = i; 9182 9247 9183 - wdev_lock(wdev); 9184 9248 for (i = 0; i < request->n_channels; i++) { 9185 9249 struct ieee80211_channel *chan = request->channels[i]; 9186 9250 ··· 9188 9254 continue; 9189 9255 9190 9256 if (!cfg80211_wdev_on_sub_chan(wdev, chan, true)) { 9191 - wdev_unlock(wdev); 9192 9257 err = -EBUSY; 9193 9258 goto out_free; 9194 9259 } 9195 9260 } 9196 - wdev_unlock(wdev); 9197 9261 9198 9262 i = 0; 9199 9263 if (n_ssids) { ··· 10197 10265 goto free; 10198 10266 } 10199 10267 10200 - wdev_lock(wdev); 10201 10268 err = rdev_channel_switch(rdev, dev, &params); 10202 - wdev_unlock(wdev); 10203 10269 10204 10270 free: 10205 10271 kfree(params.beacon_after.mbssid_ies); ··· 10220 10290 void *hdr; 10221 10291 struct nlattr *bss; 10222 10292 10223 - ASSERT_WDEV_LOCK(wdev); 10293 + lockdep_assert_wiphy(wdev->wiphy); 10224 10294 10225 10295 hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).portid, seq, flags, 10226 10296 NL80211_CMD_NEW_SCAN_RESULTS); ··· 10369 10439 /* nl80211_prepare_wdev_dump acquired it in the successful case */ 10370 10440 __acquire(&rdev->wiphy.mtx); 10371 10441 10372 - wdev_lock(wdev); 10373 10442 spin_lock_bh(&rdev->bss_lock); 10374 10443 10375 10444 /* ··· 10394 10465 } 10395 10466 10396 10467 spin_unlock_bh(&rdev->bss_lock); 10397 - wdev_unlock(wdev); 10398 10468 10399 10469 cb->args[2] = idx; 10400 10470 wiphy_unlock(&rdev->wiphy); ··· 10516 10588 } 10517 10589 10518 10590 while (1) { 10519 - wdev_lock(wdev); 10520 10591 res = rdev_dump_survey(rdev, wdev->netdev, survey_idx, &survey); 10521 - wdev_unlock(wdev); 10522 10592 if (res == -ENOENT) 10523 10593 break; 10524 10594 if (res) ··· 10689 10763 if (!req.bss) 10690 10764 return -ENOENT; 10691 10765 10692 - wdev_lock(dev->ieee80211_ptr); 10693 10766 err = cfg80211_mlme_auth(rdev, dev, &req); 10694 - wdev_unlock(dev->ieee80211_ptr); 10695 10767 10696 10768 cfg80211_put_bss(&rdev->wiphy, req.bss); 10697 10769 ··· 11104 11180 11105 11181 err = nl80211_crypto_settings(rdev, info, &req.crypto, 1); 11106 11182 if (!err) { 11107 - wdev_lock(dev->ieee80211_ptr); 11108 - 11109 11183 err = cfg80211_mlme_assoc(rdev, dev, &req); 11110 11184 11111 11185 if (!err && info->attrs[NL80211_ATTR_SOCKET_OWNER]) { ··· 11112 11190 memcpy(dev->ieee80211_ptr->disconnect_bssid, 11113 11191 ap_addr, ETH_ALEN); 11114 11192 } 11115 - 11116 - wdev_unlock(dev->ieee80211_ptr); 11117 11193 } 11118 11194 11119 11195 free: ··· 11128 11208 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 11129 11209 struct net_device *dev = info->user_ptr[1]; 11130 11210 const u8 *ie = NULL, *bssid; 11131 - int ie_len = 0, err; 11211 + int ie_len = 0; 11132 11212 u16 reason_code; 11133 11213 bool local_state_change; 11134 11214 ··· 11164 11244 11165 11245 local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; 11166 11246 11167 - wdev_lock(dev->ieee80211_ptr); 11168 - err = cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason_code, 11169 - local_state_change); 11170 - wdev_unlock(dev->ieee80211_ptr); 11171 - return err; 11247 + return cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason_code, 11248 + local_state_change); 11172 11249 } 11173 11250 11174 11251 static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info) ··· 11173 11256 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 11174 11257 struct net_device *dev = info->user_ptr[1]; 11175 11258 const u8 *ie = NULL, *bssid; 11176 - int ie_len = 0, err; 11259 + int ie_len = 0; 11177 11260 u16 reason_code; 11178 11261 bool local_state_change; 11179 11262 ··· 11209 11292 11210 11293 local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; 11211 11294 11212 - wdev_lock(dev->ieee80211_ptr); 11213 - err = cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason_code, 11214 - local_state_change); 11215 - wdev_unlock(dev->ieee80211_ptr); 11216 - return err; 11295 + return cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason_code, 11296 + local_state_change); 11217 11297 } 11218 11298 11219 11299 static bool ··· 11388 11474 ibss.userspace_handles_dfs = 11389 11475 nla_get_flag(info->attrs[NL80211_ATTR_HANDLE_DFS]); 11390 11476 11391 - wdev_lock(dev->ieee80211_ptr); 11392 11477 err = __cfg80211_join_ibss(rdev, dev, &ibss, connkeys); 11393 11478 if (err) 11394 11479 kfree_sensitive(connkeys); 11395 11480 else if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) 11396 11481 dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid; 11397 - wdev_unlock(dev->ieee80211_ptr); 11398 11482 11399 11483 return err; 11400 11484 } ··· 11925 12013 if (nla_get_flag(info->attrs[NL80211_ATTR_MLO_SUPPORT])) 11926 12014 connect.flags |= CONNECT_REQ_MLO_SUPPORT; 11927 12015 11928 - wdev_lock(dev->ieee80211_ptr); 11929 - 11930 12016 err = cfg80211_connect(rdev, dev, &connect, connkeys, 11931 12017 connect.prev_bssid); 11932 12018 if (err) ··· 11939 12029 eth_zero_addr(dev->ieee80211_ptr->disconnect_bssid); 11940 12030 } 11941 12031 11942 - wdev_unlock(dev->ieee80211_ptr); 11943 - 11944 12032 return err; 11945 12033 } 11946 12034 ··· 11952 12044 bool fils_sk_offload; 11953 12045 u32 auth_type; 11954 12046 u32 changed = 0; 11955 - int ret; 11956 12047 11957 12048 if (!rdev->ops->update_connect_params) 11958 12049 return -EOPNOTSUPP; ··· 12012 12105 changed |= UPDATE_AUTH_TYPE; 12013 12106 } 12014 12107 12015 - wdev_lock(dev->ieee80211_ptr); 12016 12108 if (!wdev->connected) 12017 - ret = -ENOLINK; 12018 - else 12019 - ret = rdev_update_connect_params(rdev, dev, &connect, changed); 12020 - wdev_unlock(dev->ieee80211_ptr); 12109 + return -ENOLINK; 12021 12110 12022 - return ret; 12111 + return rdev_update_connect_params(rdev, dev, &connect, changed); 12023 12112 } 12024 12113 12025 12114 static int nl80211_disconnect(struct sk_buff *skb, struct genl_info *info) ··· 12023 12120 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 12024 12121 struct net_device *dev = info->user_ptr[1]; 12025 12122 u16 reason; 12026 - int ret; 12027 12123 12028 12124 if (dev->ieee80211_ptr->conn_owner_nlportid && 12029 12125 dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) ··· 12040 12138 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) 12041 12139 return -EOPNOTSUPP; 12042 12140 12043 - wdev_lock(dev->ieee80211_ptr); 12044 - ret = cfg80211_disconnect(rdev, dev, reason, true); 12045 - wdev_unlock(dev->ieee80211_ptr); 12046 - return ret; 12141 + return cfg80211_disconnect(rdev, dev, reason, true); 12047 12142 } 12048 12143 12049 12144 static int nl80211_wiphy_netns(struct sk_buff *skb, struct genl_info *info) ··· 12251 12352 if (err) 12252 12353 return err; 12253 12354 12254 - wdev_lock(wdev); 12255 12355 if (!cfg80211_off_channel_oper_allowed(wdev, chandef.chan)) { 12256 12356 const struct cfg80211_chan_def *oper_chandef, *compat_chandef; 12257 12357 ··· 12259 12361 if (WARN_ON(!oper_chandef)) { 12260 12362 /* cannot happen since we must beacon to get here */ 12261 12363 WARN_ON(1); 12262 - wdev_unlock(wdev); 12263 12364 return -EBUSY; 12264 12365 } 12265 12366 ··· 12266 12369 compat_chandef = cfg80211_chandef_compatible(&chandef, 12267 12370 oper_chandef); 12268 12371 12269 - if (compat_chandef != &chandef) { 12270 - wdev_unlock(wdev); 12372 + if (compat_chandef != &chandef) 12271 12373 return -EBUSY; 12272 - } 12273 12374 } 12274 - wdev_unlock(wdev); 12275 12375 12276 12376 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 12277 12377 if (!msg) ··· 12327 12433 unsigned int link_id = nl80211_link_id(info->attrs); 12328 12434 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 12329 12435 struct net_device *dev = info->user_ptr[1]; 12330 - struct wireless_dev *wdev = dev->ieee80211_ptr; 12331 12436 int err; 12332 12437 12333 12438 if (!rdev->ops->set_bitrate_mask) 12334 12439 return -EOPNOTSUPP; 12335 12440 12336 - wdev_lock(wdev); 12337 12441 err = nl80211_parse_tx_bitrate_mask(info, info->attrs, 12338 12442 NL80211_ATTR_TX_RATES, &mask, 12339 12443 dev, true, link_id); 12340 12444 if (err) 12341 - goto out; 12445 + return err; 12342 12446 12343 - err = rdev_set_bitrate_mask(rdev, dev, link_id, NULL, &mask); 12344 - out: 12345 - wdev_unlock(wdev); 12346 - return err; 12447 + return rdev_set_bitrate_mask(rdev, dev, link_id, NULL, &mask); 12347 12448 } 12348 12449 12349 12450 static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) ··· 12467 12578 if (!chandef.chan && params.offchan) 12468 12579 return -EINVAL; 12469 12580 12470 - wdev_lock(wdev); 12471 12581 if (params.offchan && 12472 - !cfg80211_off_channel_oper_allowed(wdev, chandef.chan)) { 12473 - wdev_unlock(wdev); 12582 + !cfg80211_off_channel_oper_allowed(wdev, chandef.chan)) 12474 12583 return -EBUSY; 12475 - } 12476 12584 12477 12585 params.link_id = nl80211_link_id_or_invalid(info->attrs); 12478 12586 /* ··· 12478 12592 * to the driver. 12479 12593 */ 12480 12594 if (params.link_id >= 0 && 12481 - !(wdev->valid_links & BIT(params.link_id))) { 12482 - wdev_unlock(wdev); 12595 + !(wdev->valid_links & BIT(params.link_id))) 12483 12596 return -EINVAL; 12484 - } 12485 - wdev_unlock(wdev); 12486 12597 12487 12598 params.buf = nla_data(info->attrs[NL80211_ATTR_FRAME]); 12488 12599 params.len = nla_len(info->attrs[NL80211_ATTR_FRAME]); ··· 12749 12866 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 12750 12867 struct net_device *dev = info->user_ptr[1]; 12751 12868 struct wireless_dev *wdev = dev->ieee80211_ptr; 12752 - int i, err; 12753 12869 s32 prev = S32_MIN; 12870 + int i; 12754 12871 12755 12872 /* Check all values negative and sorted */ 12756 12873 for (i = 0; i < n_thresholds; i++) { ··· 12764 12881 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) 12765 12882 return -EOPNOTSUPP; 12766 12883 12767 - wdev_lock(wdev); 12768 12884 cfg80211_cqm_config_free(wdev); 12769 - wdev_unlock(wdev); 12770 12885 12771 12886 if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) { 12772 12887 if (n_thresholds == 0 || thresholds[0] == 0) /* Disabling */ ··· 12781 12900 if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */ 12782 12901 n_thresholds = 0; 12783 12902 12784 - wdev_lock(wdev); 12785 12903 if (n_thresholds) { 12786 12904 struct cfg80211_cqm_config *cqm_config; 12787 12905 12788 12906 cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds, 12789 12907 n_thresholds), 12790 12908 GFP_KERNEL); 12791 - if (!cqm_config) { 12792 - err = -ENOMEM; 12793 - goto unlock; 12794 - } 12909 + if (!cqm_config) 12910 + return -ENOMEM; 12795 12911 12796 12912 cqm_config->rssi_hyst = hysteresis; 12797 12913 cqm_config->n_rssi_thresholds = n_thresholds; ··· 12799 12921 wdev->cqm_config = cqm_config; 12800 12922 } 12801 12923 12802 - err = cfg80211_cqm_rssi_update(rdev, dev); 12803 - 12804 - unlock: 12805 - wdev_unlock(wdev); 12806 - 12807 - return err; 12924 + return cfg80211_cqm_rssi_update(rdev, dev); 12808 12925 } 12809 12926 12810 12927 static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info) ··· 12981 13108 setup.control_port_over_nl80211 = true; 12982 13109 } 12983 13110 12984 - wdev_lock(dev->ieee80211_ptr); 12985 13111 err = __cfg80211_join_mesh(rdev, dev, &setup, &cfg); 12986 13112 if (!err && info->attrs[NL80211_ATTR_SOCKET_OWNER]) 12987 13113 dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid; 12988 - wdev_unlock(dev->ieee80211_ptr); 12989 13114 12990 13115 return err; 12991 13116 } ··· 13927 14056 if (tb[NL80211_REKEY_DATA_AKM]) 13928 14057 rekey_data.akm = nla_get_u32(tb[NL80211_REKEY_DATA_AKM]); 13929 14058 13930 - wdev_lock(wdev); 13931 - if (!wdev->connected) { 13932 - err = -ENOTCONN; 13933 - goto out; 13934 - } 14059 + if (!wdev->connected) 14060 + return -ENOTCONN; 13935 14061 13936 - if (!rdev->ops->set_rekey_data) { 13937 - err = -EOPNOTSUPP; 13938 - goto out; 13939 - } 14062 + if (!rdev->ops->set_rekey_data) 14063 + return -EOPNOTSUPP; 13940 14064 13941 - err = rdev_set_rekey_data(rdev, dev, &rekey_data); 13942 - out: 13943 - wdev_unlock(wdev); 13944 - return err; 14065 + return rdev_set_rekey_data(rdev, dev, &rekey_data); 13945 14066 } 13946 14067 13947 14068 static int nl80211_register_unexpected_frame(struct sk_buff *skb, ··· 15137 15274 memcpy(qos_map->up, pos, IEEE80211_QOS_MAP_LEN_MIN); 15138 15275 } 15139 15276 15140 - wdev_lock(dev->ieee80211_ptr); 15141 15277 ret = nl80211_key_allowed(dev->ieee80211_ptr); 15142 15278 if (!ret) 15143 15279 ret = rdev_set_qos_map(rdev, dev, qos_map); 15144 - wdev_unlock(dev->ieee80211_ptr); 15145 15280 15146 15281 kfree(qos_map); 15147 15282 return ret; ··· 15153 15292 const u8 *peer; 15154 15293 u8 tsid, up; 15155 15294 u16 admitted_time = 0; 15156 - int err; 15157 15295 15158 15296 if (!(rdev->wiphy.features & NL80211_FEATURE_SUPPORTS_WMM_ADMISSION)) 15159 15297 return -EOPNOTSUPP; ··· 15182 15322 return -EINVAL; 15183 15323 } 15184 15324 15185 - wdev_lock(wdev); 15186 15325 switch (wdev->iftype) { 15187 15326 case NL80211_IFTYPE_STATION: 15188 15327 case NL80211_IFTYPE_P2P_CLIENT: 15189 15328 if (wdev->connected) 15190 15329 break; 15191 - err = -ENOTCONN; 15192 - goto out; 15330 + return -ENOTCONN; 15193 15331 default: 15194 - err = -EOPNOTSUPP; 15195 - goto out; 15332 + return -EOPNOTSUPP; 15196 15333 } 15197 15334 15198 - err = rdev_add_tx_ts(rdev, dev, tsid, peer, up, admitted_time); 15199 - 15200 - out: 15201 - wdev_unlock(wdev); 15202 - return err; 15335 + return rdev_add_tx_ts(rdev, dev, tsid, peer, up, admitted_time); 15203 15336 } 15204 15337 15205 15338 static int nl80211_del_tx_ts(struct sk_buff *skb, struct genl_info *info) 15206 15339 { 15207 15340 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 15208 15341 struct net_device *dev = info->user_ptr[1]; 15209 - struct wireless_dev *wdev = dev->ieee80211_ptr; 15210 15342 const u8 *peer; 15211 15343 u8 tsid; 15212 - int err; 15213 15344 15214 15345 if (!info->attrs[NL80211_ATTR_TSID] || !info->attrs[NL80211_ATTR_MAC]) 15215 15346 return -EINVAL; ··· 15208 15357 tsid = nla_get_u8(info->attrs[NL80211_ATTR_TSID]); 15209 15358 peer = nla_data(info->attrs[NL80211_ATTR_MAC]); 15210 15359 15211 - wdev_lock(wdev); 15212 - err = rdev_del_tx_ts(rdev, dev, tsid, peer); 15213 - wdev_unlock(wdev); 15214 - 15215 - return err; 15360 + return rdev_del_tx_ts(rdev, dev, tsid, peer); 15216 15361 } 15217 15362 15218 15363 static int nl80211_tdls_channel_switch(struct sk_buff *skb, ··· 15264 15417 addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 15265 15418 oper_class = nla_get_u8(info->attrs[NL80211_ATTR_OPER_CLASS]); 15266 15419 15267 - wdev_lock(wdev); 15268 - err = rdev_tdls_channel_switch(rdev, dev, addr, oper_class, &chandef); 15269 - wdev_unlock(wdev); 15270 - 15271 - return err; 15420 + return rdev_tdls_channel_switch(rdev, dev, addr, oper_class, &chandef); 15272 15421 } 15273 15422 15274 15423 static int nl80211_tdls_cancel_channel_switch(struct sk_buff *skb, ··· 15272 15429 { 15273 15430 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 15274 15431 struct net_device *dev = info->user_ptr[1]; 15275 - struct wireless_dev *wdev = dev->ieee80211_ptr; 15276 15432 const u8 *addr; 15277 15433 15278 15434 if (!rdev->ops->tdls_channel_switch || ··· 15292 15450 15293 15451 addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 15294 15452 15295 - wdev_lock(wdev); 15296 15453 rdev_tdls_cancel_channel_switch(rdev, dev, addr); 15297 - wdev_unlock(wdev); 15298 15454 15299 15455 return 0; 15300 15456 } ··· 15325 15485 struct net_device *dev = info->user_ptr[1]; 15326 15486 struct wireless_dev *wdev = dev->ieee80211_ptr; 15327 15487 struct cfg80211_pmk_conf pmk_conf = {}; 15328 - int ret; 15329 15488 15330 15489 if (wdev->iftype != NL80211_IFTYPE_STATION && 15331 15490 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) ··· 15337 15498 if (!info->attrs[NL80211_ATTR_MAC] || !info->attrs[NL80211_ATTR_PMK]) 15338 15499 return -EINVAL; 15339 15500 15340 - wdev_lock(wdev); 15341 - if (!wdev->connected) { 15342 - ret = -ENOTCONN; 15343 - goto out; 15344 - } 15501 + if (!wdev->connected) 15502 + return -ENOTCONN; 15345 15503 15346 15504 pmk_conf.aa = nla_data(info->attrs[NL80211_ATTR_MAC]); 15347 - if (memcmp(pmk_conf.aa, wdev->u.client.connected_addr, ETH_ALEN)) { 15348 - ret = -EINVAL; 15349 - goto out; 15350 - } 15505 + if (memcmp(pmk_conf.aa, wdev->u.client.connected_addr, ETH_ALEN)) 15506 + return -EINVAL; 15351 15507 15352 15508 pmk_conf.pmk = nla_data(info->attrs[NL80211_ATTR_PMK]); 15353 15509 pmk_conf.pmk_len = nla_len(info->attrs[NL80211_ATTR_PMK]); 15354 15510 if (pmk_conf.pmk_len != WLAN_PMK_LEN && 15355 - pmk_conf.pmk_len != WLAN_PMK_LEN_SUITE_B_192) { 15356 - ret = -EINVAL; 15357 - goto out; 15358 - } 15511 + pmk_conf.pmk_len != WLAN_PMK_LEN_SUITE_B_192) 15512 + return -EINVAL; 15359 15513 15360 15514 if (info->attrs[NL80211_ATTR_PMKR0_NAME]) 15361 15515 pmk_conf.pmk_r0_name = 15362 15516 nla_data(info->attrs[NL80211_ATTR_PMKR0_NAME]); 15363 15517 15364 - ret = rdev_set_pmk(rdev, dev, &pmk_conf); 15365 - out: 15366 - wdev_unlock(wdev); 15367 - return ret; 15518 + return rdev_set_pmk(rdev, dev, &pmk_conf); 15368 15519 } 15369 15520 15370 15521 static int nl80211_del_pmk(struct sk_buff *skb, struct genl_info *info) ··· 15363 15534 struct net_device *dev = info->user_ptr[1]; 15364 15535 struct wireless_dev *wdev = dev->ieee80211_ptr; 15365 15536 const u8 *aa; 15366 - int ret; 15367 15537 15368 15538 if (wdev->iftype != NL80211_IFTYPE_STATION && 15369 15539 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) ··· 15375 15547 if (!info->attrs[NL80211_ATTR_MAC]) 15376 15548 return -EINVAL; 15377 15549 15378 - wdev_lock(wdev); 15379 15550 aa = nla_data(info->attrs[NL80211_ATTR_MAC]); 15380 - ret = rdev_del_pmk(rdev, dev, aa); 15381 - wdev_unlock(wdev); 15382 - 15383 - return ret; 15551 + return rdev_del_pmk(rdev, dev, aa); 15384 15552 } 15385 15553 15386 15554 static int nl80211_external_auth(struct sk_buff *skb, struct genl_info *info) ··· 15450 15626 return -EINVAL; 15451 15627 } 15452 15628 15453 - wdev_lock(wdev); 15454 - 15455 15629 switch (wdev->iftype) { 15456 15630 case NL80211_IFTYPE_AP: 15457 15631 case NL80211_IFTYPE_P2P_GO: ··· 15458 15636 case NL80211_IFTYPE_ADHOC: 15459 15637 if (wdev->u.ibss.current_bss) 15460 15638 break; 15461 - err = -ENOTCONN; 15462 - goto out; 15639 + return -ENOTCONN; 15463 15640 case NL80211_IFTYPE_STATION: 15464 15641 case NL80211_IFTYPE_P2P_CLIENT: 15465 15642 if (wdev->connected) 15466 15643 break; 15467 - err = -ENOTCONN; 15468 - goto out; 15644 + return -ENOTCONN; 15469 15645 default: 15470 - err = -EOPNOTSUPP; 15471 - goto out; 15646 + return -EOPNOTSUPP; 15472 15647 } 15473 - 15474 - wdev_unlock(wdev); 15475 15648 15476 15649 buf = nla_data(info->attrs[NL80211_ATTR_FRAME]); 15477 15650 len = nla_len(info->attrs[NL80211_ATTR_FRAME]); ··· 15482 15665 dont_wait_for_ack ? NULL : &cookie); 15483 15666 if (!err && !dont_wait_for_ack) 15484 15667 nl_set_extack_cookie_u64(info->extack, cookie); 15485 - return err; 15486 - out: 15487 - wdev_unlock(wdev); 15488 15668 return err; 15489 15669 } 15490 15670 ··· 15760 15946 if (info->attrs[NL80211_ATTR_MAC]) 15761 15947 tid_config->peer = nla_data(info->attrs[NL80211_ATTR_MAC]); 15762 15948 15763 - wdev_lock(dev->ieee80211_ptr); 15764 - 15765 15949 nla_for_each_nested(tid, info->attrs[NL80211_ATTR_TID_CONFIG], 15766 15950 rem_conf) { 15767 15951 ret = nla_parse_nested(attrs, NL80211_TID_CONFIG_ATTR_MAX, ··· 15781 15969 15782 15970 bad_tid_conf: 15783 15971 kfree(tid_config); 15784 - wdev_unlock(dev->ieee80211_ptr); 15785 15972 return ret; 15786 15973 } 15787 15974 ··· 15877 16066 params.counter_offset_presp = offset; 15878 16067 } 15879 16068 15880 - wdev_lock(wdev); 15881 16069 err = rdev_color_change(rdev, dev, &params); 15882 - wdev_unlock(wdev); 15883 16070 15884 16071 out: 15885 16072 kfree(params.beacon_next.mbssid_ies); ··· 15933 16124 !is_valid_ether_addr(nla_data(info->attrs[NL80211_ATTR_MAC]))) 15934 16125 return -EINVAL; 15935 16126 15936 - wdev_lock(wdev); 15937 16127 wdev->valid_links |= BIT(link_id); 15938 16128 ether_addr_copy(wdev->links[link_id].addr, 15939 16129 nla_data(info->attrs[NL80211_ATTR_MAC])); ··· 15942 16134 wdev->valid_links &= ~BIT(link_id); 15943 16135 eth_zero_addr(wdev->links[link_id].addr); 15944 16136 } 15945 - wdev_unlock(wdev); 15946 16137 15947 16138 return ret; 15948 16139 } ··· 15963 16156 return -EINVAL; 15964 16157 } 15965 16158 15966 - wdev_lock(wdev); 15967 16159 cfg80211_remove_link(wdev, link_id); 15968 - wdev_unlock(wdev); 15969 16160 15970 16161 return 0; 15971 16162 } ··· 16053 16248 if (err) 16054 16249 return err; 16055 16250 16056 - wdev_lock(dev->ieee80211_ptr); 16057 16251 if (add) 16058 - err = rdev_add_link_station(rdev, dev, &params); 16059 - else 16060 - err = rdev_mod_link_station(rdev, dev, &params); 16061 - wdev_unlock(dev->ieee80211_ptr); 16252 + return rdev_add_link_station(rdev, dev, &params); 16062 16253 16063 - return err; 16254 + return rdev_mod_link_station(rdev, dev, &params); 16064 16255 } 16065 16256 16066 16257 static int ··· 16077 16276 struct link_station_del_parameters params = {}; 16078 16277 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 16079 16278 struct net_device *dev = info->user_ptr[1]; 16080 - int ret; 16081 16279 16082 16280 if (!rdev->ops->del_link_station) 16083 16281 return -EOPNOTSUPP; ··· 16088 16288 params.mld_mac = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); 16089 16289 params.link_id = nla_get_u8(info->attrs[NL80211_ATTR_MLO_LINK_ID]); 16090 16290 16091 - wdev_lock(dev->ieee80211_ptr); 16092 - ret = rdev_del_link_station(rdev, dev, &params); 16093 - wdev_unlock(dev->ieee80211_ptr); 16094 - 16095 - return ret; 16291 + return rdev_del_link_station(rdev, dev, &params); 16096 16292 } 16097 16293 16098 16294 static int nl80211_set_hw_timestamp(struct sk_buff *skb, ··· 18096 18300 struct nlattr *links; 18097 18301 void *hdr; 18098 18302 18099 - ASSERT_WDEV_LOCK(wdev); 18303 + lockdep_assert_wiphy(wdev->wiphy); 18100 18304 trace_cfg80211_links_removed(dev, link_mask); 18101 18305 18102 18306 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && ··· 19150 19354 struct wiphy *wiphy = wdev->wiphy; 19151 19355 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 19152 19356 19153 - ASSERT_WDEV_LOCK(wdev); 19357 + lockdep_assert_wiphy(wdev->wiphy); 19154 19358 WARN_INVALID_LINK_ID(wdev, link_id); 19155 19359 19156 19360 trace_cfg80211_ch_switch_notify(dev, chandef, link_id, punct_bitmap); ··· 19195 19399 struct wiphy *wiphy = wdev->wiphy; 19196 19400 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 19197 19401 19198 - ASSERT_WDEV_LOCK(wdev); 19402 + lockdep_assert_wiphy(wdev->wiphy); 19199 19403 WARN_INVALID_LINK_ID(wdev, link_id); 19200 19404 19201 19405 trace_cfg80211_ch_switch_started_notify(dev, chandef, link_id, ··· 19218 19422 struct sk_buff *msg; 19219 19423 void *hdr; 19220 19424 19221 - ASSERT_WDEV_LOCK(wdev); 19425 + lockdep_assert_wiphy(wdev->wiphy); 19222 19426 19223 19427 trace_cfg80211_bss_color_notify(dev, cmd, count, color_bitmap); 19224 19428
+8 -35
net/wireless/ocb.c
··· 4 4 * 5 5 * Copyright: (c) 2014 Czech Technical University in Prague 6 6 * (c) 2014 Volkswagen Group Research 7 - * Copyright (C) 2022 Intel Corporation 7 + * Copyright (C) 2022-2023 Intel Corporation 8 8 * Author: Rostislav Lisovy <rostislav.lisovy@fel.cvut.cz> 9 9 * Funded by: Volkswagen Group Research 10 10 */ ··· 15 15 #include "core.h" 16 16 #include "rdev-ops.h" 17 17 18 - int __cfg80211_join_ocb(struct cfg80211_registered_device *rdev, 19 - struct net_device *dev, 20 - struct ocb_setup *setup) 18 + int cfg80211_join_ocb(struct cfg80211_registered_device *rdev, 19 + struct net_device *dev, 20 + struct ocb_setup *setup) 21 21 { 22 22 struct wireless_dev *wdev = dev->ieee80211_ptr; 23 23 int err; 24 24 25 - ASSERT_WDEV_LOCK(wdev); 25 + lockdep_assert_wiphy(wdev->wiphy); 26 26 27 27 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_OCB) 28 28 return -EOPNOTSUPP; ··· 40 40 return err; 41 41 } 42 42 43 - int cfg80211_join_ocb(struct cfg80211_registered_device *rdev, 44 - struct net_device *dev, 45 - struct ocb_setup *setup) 43 + int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev, 44 + struct net_device *dev) 46 45 { 47 46 struct wireless_dev *wdev = dev->ieee80211_ptr; 48 47 int err; 49 48 50 - wdev_lock(wdev); 51 - err = __cfg80211_join_ocb(rdev, dev, setup); 52 - wdev_unlock(wdev); 53 - 54 - return err; 55 - } 56 - 57 - int __cfg80211_leave_ocb(struct cfg80211_registered_device *rdev, 58 - struct net_device *dev) 59 - { 60 - struct wireless_dev *wdev = dev->ieee80211_ptr; 61 - int err; 62 - 63 - ASSERT_WDEV_LOCK(wdev); 49 + lockdep_assert_wiphy(wdev->wiphy); 64 50 65 51 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_OCB) 66 52 return -EOPNOTSUPP; ··· 60 74 err = rdev_leave_ocb(rdev, dev); 61 75 if (!err) 62 76 memset(&wdev->u.ocb.chandef, 0, sizeof(wdev->u.ocb.chandef)); 63 - 64 - return err; 65 - } 66 - 67 - int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev, 68 - struct net_device *dev) 69 - { 70 - struct wireless_dev *wdev = dev->ieee80211_ptr; 71 - int err; 72 - 73 - wdev_lock(wdev); 74 - err = __cfg80211_leave_ocb(rdev, dev); 75 - wdev_unlock(wdev); 76 77 77 78 return err; 78 79 }
+1 -3
net/wireless/pmsr.c
··· 600 600 struct cfg80211_pmsr_request *req, *tmp; 601 601 LIST_HEAD(free_list); 602 602 603 - lockdep_assert_held(&wdev->mtx); 603 + lockdep_assert_wiphy(wdev->wiphy); 604 604 605 605 spin_lock_bh(&wdev->pmsr_lock); 606 606 list_for_each_entry_safe(req, tmp, &wdev->pmsr_list, list) { ··· 623 623 pmsr_free_wk); 624 624 625 625 wiphy_lock(wdev->wiphy); 626 - wdev_lock(wdev); 627 626 cfg80211_pmsr_process_abort(wdev); 628 - wdev_unlock(wdev); 629 627 wiphy_unlock(wdev->wiphy); 630 628 } 631 629
+1 -15
net/wireless/reg.c
··· 2342 2342 bool ret; 2343 2343 int link; 2344 2344 2345 - wdev_lock(wdev); 2346 2345 iftype = wdev->iftype; 2347 2346 2348 2347 /* make sure the interface is active */ 2349 2348 if (!wdev->netdev || !netif_running(wdev->netdev)) 2350 - goto wdev_inactive_unlock; 2349 + return true; 2351 2350 2352 2351 for (link = 0; link < ARRAY_SIZE(wdev->links); link++) { 2353 2352 struct ieee80211_channel *chan; ··· 2406 2407 break; 2407 2408 } 2408 2409 2409 - wdev_unlock(wdev); 2410 - 2411 2410 switch (iftype) { 2412 2411 case NL80211_IFTYPE_AP: 2413 2412 case NL80211_IFTYPE_P2P_GO: ··· 2426 2429 default: 2427 2430 break; 2428 2431 } 2429 - 2430 - wdev_lock(wdev); 2431 2432 } 2432 2433 2433 - wdev_unlock(wdev); 2434 - 2435 - return true; 2436 - 2437 - wdev_inactive_unlock: 2438 - wdev_unlock(wdev); 2439 2434 return true; 2440 2435 } 2441 2436 ··· 3566 3577 for_each_rdev(rdev) { 3567 3578 wiphy_lock(&rdev->wiphy); 3568 3579 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { 3569 - wdev_lock(wdev); 3570 3580 if (!(wdev->wiphy->regulatory_flags & flag)) { 3571 - wdev_unlock(wdev); 3572 3581 wiphy_unlock(&rdev->wiphy); 3573 3582 return false; 3574 3583 } 3575 - wdev_unlock(wdev); 3576 3584 } 3577 3585 wiphy_unlock(&rdev->wiphy); 3578 3586 }
+19 -36
net/wireless/sme.c
··· 67 67 struct cfg80211_scan_request *request; 68 68 int n_channels, err; 69 69 70 - ASSERT_WDEV_LOCK(wdev); 70 + lockdep_assert_wiphy(wdev->wiphy); 71 71 72 72 if (rdev->scan_req || rdev->scan_msg) 73 73 return -EBUSY; ··· 151 151 struct cfg80211_assoc_request req = {}; 152 152 int err; 153 153 154 - ASSERT_WDEV_LOCK(wdev); 154 + lockdep_assert_wiphy(wdev->wiphy); 155 155 156 156 if (!wdev->conn) 157 157 return 0; ··· 255 255 if (!wdev->netdev) 256 256 continue; 257 257 258 - wdev_lock(wdev); 259 - if (!netif_running(wdev->netdev)) { 260 - wdev_unlock(wdev); 258 + if (!netif_running(wdev->netdev)) 261 259 continue; 262 - } 260 + 263 261 if (!wdev->conn || 264 - wdev->conn->state == CFG80211_CONN_CONNECTED) { 265 - wdev_unlock(wdev); 262 + wdev->conn->state == CFG80211_CONN_CONNECTED) 266 263 continue; 267 - } 264 + 268 265 if (wdev->conn->params.bssid) { 269 266 memcpy(bssid_buf, wdev->conn->params.bssid, ETH_ALEN); 270 267 bssid = bssid_buf; ··· 276 279 cr.timeout_reason = treason; 277 280 __cfg80211_connect_result(wdev->netdev, &cr, false); 278 281 } 279 - wdev_unlock(wdev); 280 282 } 281 283 282 284 wiphy_unlock(&rdev->wiphy); ··· 296 300 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 297 301 struct cfg80211_bss *bss; 298 302 299 - ASSERT_WDEV_LOCK(wdev); 303 + lockdep_assert_wiphy(wdev->wiphy); 300 304 301 305 bss = cfg80211_get_bss(wdev->wiphy, wdev->conn->params.channel, 302 306 wdev->conn->params.bssid, ··· 313 317 return bss; 314 318 } 315 319 316 - static void __cfg80211_sme_scan_done(struct net_device *dev) 320 + void cfg80211_sme_scan_done(struct net_device *dev) 317 321 { 318 322 struct wireless_dev *wdev = dev->ieee80211_ptr; 319 323 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 320 324 struct cfg80211_bss *bss; 321 325 322 - ASSERT_WDEV_LOCK(wdev); 326 + lockdep_assert_wiphy(wdev->wiphy); 323 327 324 328 if (!wdev->conn) 325 329 return; ··· 335 339 schedule_work(&rdev->conn_work); 336 340 } 337 341 338 - void cfg80211_sme_scan_done(struct net_device *dev) 339 - { 340 - struct wireless_dev *wdev = dev->ieee80211_ptr; 341 - 342 - wdev_lock(wdev); 343 - __cfg80211_sme_scan_done(dev); 344 - wdev_unlock(wdev); 345 - } 346 - 347 342 void cfg80211_sme_rx_auth(struct wireless_dev *wdev, const u8 *buf, size_t len) 348 343 { 349 344 struct wiphy *wiphy = wdev->wiphy; ··· 342 355 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; 343 356 u16 status_code = le16_to_cpu(mgmt->u.auth.status_code); 344 357 345 - ASSERT_WDEV_LOCK(wdev); 358 + lockdep_assert_wiphy(wdev->wiphy); 346 359 347 360 if (!wdev->conn || wdev->conn->state == CFG80211_CONN_CONNECTED) 348 361 return; ··· 692 705 for_each_rdev(rdev) { 693 706 wiphy_lock(&rdev->wiphy); 694 707 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { 695 - wdev_lock(wdev); 696 708 if (wdev->conn || wdev->connected || 697 709 cfg80211_beaconing_iface_active(wdev)) 698 710 is_all_idle = false; 699 - wdev_unlock(wdev); 700 711 } 701 712 wiphy_unlock(&rdev->wiphy); 702 713 } ··· 748 763 const u8 *connected_addr; 749 764 bool bss_not_found = false; 750 765 751 - ASSERT_WDEV_LOCK(wdev); 766 + lockdep_assert_wiphy(wdev->wiphy); 752 767 753 768 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && 754 769 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) ··· 1080 1095 unsigned int link; 1081 1096 const u8 *connected_addr; 1082 1097 1083 - ASSERT_WDEV_LOCK(wdev); 1098 + lockdep_assert_wiphy(wdev->wiphy); 1084 1099 1085 1100 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && 1086 1101 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) ··· 1284 1299 void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *bssid, 1285 1300 const u8 *td_bitmap, u8 td_bitmap_len) 1286 1301 { 1287 - ASSERT_WDEV_LOCK(wdev); 1302 + lockdep_assert_wiphy(wdev->wiphy); 1288 1303 1289 1304 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && 1290 1305 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) ··· 1340 1355 union iwreq_data wrqu; 1341 1356 #endif 1342 1357 1343 - ASSERT_WDEV_LOCK(wdev); 1358 + lockdep_assert_wiphy(wdev->wiphy); 1344 1359 1345 1360 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && 1346 1361 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) ··· 1430 1445 struct wireless_dev *wdev = dev->ieee80211_ptr; 1431 1446 int err; 1432 1447 1433 - ASSERT_WDEV_LOCK(wdev); 1448 + lockdep_assert_wiphy(wdev->wiphy); 1434 1449 1435 1450 /* 1436 1451 * If we have an ssid_len, we're trying to connect or are ··· 1536 1551 struct wireless_dev *wdev = dev->ieee80211_ptr; 1537 1552 int err = 0; 1538 1553 1539 - ASSERT_WDEV_LOCK(wdev); 1554 + lockdep_assert_wiphy(wdev->wiphy); 1540 1555 1541 1556 kfree_sensitive(wdev->connect_keys); 1542 1557 wdev->connect_keys = NULL; ··· 1572 1587 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 1573 1588 1574 1589 wiphy_lock(wdev->wiphy); 1575 - wdev_lock(wdev); 1576 1590 1577 1591 if (wdev->conn_owner_nlportid) { 1578 1592 switch (wdev->iftype) { 1579 1593 case NL80211_IFTYPE_ADHOC: 1580 - __cfg80211_leave_ibss(rdev, wdev->netdev, false); 1594 + cfg80211_leave_ibss(rdev, wdev->netdev, false); 1581 1595 break; 1582 1596 case NL80211_IFTYPE_AP: 1583 1597 case NL80211_IFTYPE_P2P_GO: 1584 - __cfg80211_stop_ap(rdev, wdev->netdev, -1, false); 1598 + cfg80211_stop_ap(rdev, wdev->netdev, -1, false); 1585 1599 break; 1586 1600 case NL80211_IFTYPE_MESH_POINT: 1587 - __cfg80211_leave_mesh(rdev, wdev->netdev); 1601 + cfg80211_leave_mesh(rdev, wdev->netdev); 1588 1602 break; 1589 1603 case NL80211_IFTYPE_STATION: 1590 1604 case NL80211_IFTYPE_P2P_CLIENT: ··· 1608 1624 } 1609 1625 } 1610 1626 1611 - wdev_unlock(wdev); 1612 1627 wiphy_unlock(wdev->wiphy); 1613 1628 }
+3 -11
net/wireless/util.c
··· 1044 1044 list_del(&ev->list); 1045 1045 spin_unlock_irqrestore(&wdev->event_lock, flags); 1046 1046 1047 - wdev_lock(wdev); 1048 1047 switch (ev->type) { 1049 1048 case EVENT_CONNECT_RESULT: 1050 1049 __cfg80211_connect_result( ··· 1065 1066 ev->ij.channel); 1066 1067 break; 1067 1068 case EVENT_STOPPED: 1068 - __cfg80211_leave(wiphy_to_rdev(wdev->wiphy), wdev); 1069 + cfg80211_leave(wiphy_to_rdev(wdev->wiphy), wdev); 1069 1070 break; 1070 1071 case EVENT_PORT_AUTHORIZED: 1071 1072 __cfg80211_port_authorized(wdev, ev->pa.bssid, ··· 1073 1074 ev->pa.td_bitmap_len); 1074 1075 break; 1075 1076 } 1076 - wdev_unlock(wdev); 1077 1077 1078 1078 kfree(ev); 1079 1079 ··· 1122 1124 return -EBUSY; 1123 1125 1124 1126 dev->ieee80211_ptr->use_4addr = false; 1125 - wdev_lock(dev->ieee80211_ptr); 1126 1127 rdev_set_qos_map(rdev, dev, NULL); 1127 - wdev_unlock(dev->ieee80211_ptr); 1128 1128 1129 1129 switch (otype) { 1130 1130 case NL80211_IFTYPE_AP: ··· 1134 1138 break; 1135 1139 case NL80211_IFTYPE_STATION: 1136 1140 case NL80211_IFTYPE_P2P_CLIENT: 1137 - wdev_lock(dev->ieee80211_ptr); 1138 1141 cfg80211_disconnect(rdev, dev, 1139 1142 WLAN_REASON_DEAUTH_LEAVING, true); 1140 - wdev_unlock(dev->ieee80211_ptr); 1141 1143 break; 1142 1144 case NL80211_IFTYPE_MESH_POINT: 1143 1145 /* mesh should be handled? */ ··· 2641 2647 { 2642 2648 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 2643 2649 2644 - ASSERT_WDEV_LOCK(wdev); 2650 + lockdep_assert_wiphy(wdev->wiphy); 2645 2651 2646 2652 switch (wdev->iftype) { 2647 2653 case NL80211_IFTYPE_AP: 2648 2654 case NL80211_IFTYPE_P2P_GO: 2649 - __cfg80211_stop_ap(rdev, wdev->netdev, link_id, true); 2655 + cfg80211_stop_ap(rdev, wdev->netdev, link_id, true); 2650 2656 break; 2651 2657 default: 2652 2658 /* per-link not relevant */ ··· 2671 2677 if (wdev->iftype != NL80211_IFTYPE_AP) 2672 2678 return; 2673 2679 2674 - wdev_lock(wdev); 2675 2680 if (wdev->valid_links) { 2676 2681 for_each_valid_link(wdev, link_id) 2677 2682 cfg80211_remove_link(wdev, link_id); 2678 2683 } 2679 - wdev_unlock(wdev); 2680 2684 } 2681 2685 2682 2686 int cfg80211_remove_virtual_intf(struct cfg80211_registered_device *rdev,
+9 -34
net/wireless/wext-compat.c
··· 415 415 } 416 416 EXPORT_WEXT_HANDLER(cfg80211_wext_giwretry); 417 417 418 - static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, 419 - struct net_device *dev, bool pairwise, 420 - const u8 *addr, bool remove, bool tx_key, 421 - int idx, struct key_params *params) 418 + static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev, 419 + struct net_device *dev, bool pairwise, 420 + const u8 *addr, bool remove, bool tx_key, 421 + int idx, struct key_params *params) 422 422 { 423 423 struct wireless_dev *wdev = dev->ieee80211_ptr; 424 424 int err, i; ··· 471 471 */ 472 472 if (idx == wdev->wext.default_key && 473 473 wdev->iftype == NL80211_IFTYPE_ADHOC) { 474 - __cfg80211_leave_ibss(rdev, wdev->netdev, true); 474 + cfg80211_leave_ibss(rdev, wdev->netdev, true); 475 475 rejoin = true; 476 476 } 477 477 ··· 552 552 */ 553 553 if (wdev->iftype == NL80211_IFTYPE_ADHOC && 554 554 wdev->wext.default_key == -1) { 555 - __cfg80211_leave_ibss(rdev, wdev->netdev, true); 555 + cfg80211_leave_ibss(rdev, wdev->netdev, true); 556 556 rejoin = true; 557 557 } 558 558 err = rdev_set_default_key(rdev, dev, -1, idx, true, ··· 578 578 } 579 579 580 580 return 0; 581 - } 582 - 583 - static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev, 584 - struct net_device *dev, bool pairwise, 585 - const u8 *addr, bool remove, bool tx_key, 586 - int idx, struct key_params *params) 587 - { 588 - int err; 589 - 590 - wdev_lock(dev->ieee80211_ptr); 591 - err = __cfg80211_set_encryption(rdev, dev, pairwise, addr, 592 - remove, tx_key, idx, params); 593 - wdev_unlock(dev->ieee80211_ptr); 594 - 595 - return err; 596 581 } 597 582 598 583 static int cfg80211_wext_siwencode(struct net_device *dev, ··· 624 639 else if (erq->length == 0) { 625 640 /* No key data - just set the default TX key index */ 626 641 err = 0; 627 - wdev_lock(wdev); 628 642 if (wdev->connected || 629 643 (wdev->iftype == NL80211_IFTYPE_ADHOC && 630 644 wdev->u.ibss.current_bss)) ··· 631 647 true); 632 648 if (!err) 633 649 wdev->wext.default_key = idx; 634 - wdev_unlock(wdev); 635 650 goto out; 636 651 } 637 652 ··· 680 697 !rdev->ops->set_default_key) 681 698 return -EOPNOTSUPP; 682 699 683 - wdev_lock(wdev); 684 - if (wdev->valid_links) { 685 - wdev_unlock(wdev); 700 + if (wdev->valid_links) 686 701 return -EOPNOTSUPP; 687 - } 688 - wdev_unlock(wdev); 689 702 690 703 switch (ext->alg) { 691 704 case IW_ENCODE_ALG_NONE: ··· 1320 1341 return -EOPNOTSUPP; 1321 1342 1322 1343 err = 0; 1323 - wdev_lock(wdev); 1324 1344 if (!wdev->valid_links && wdev->links[0].client.current_bss) 1325 1345 memcpy(addr, wdev->links[0].client.current_bss->pub.bssid, 1326 1346 ETH_ALEN); 1327 1347 else 1328 1348 err = -EOPNOTSUPP; 1329 - wdev_unlock(wdev); 1330 1349 if (err) 1331 1350 return err; 1332 1351 ··· 1364 1387 return NULL; 1365 1388 1366 1389 /* Grab BSSID of current BSS, if any */ 1367 - wdev_lock(wdev); 1390 + wiphy_lock(&rdev->wiphy); 1368 1391 if (wdev->valid_links || !wdev->links[0].client.current_bss) { 1369 - wdev_unlock(wdev); 1392 + wiphy_unlock(&rdev->wiphy); 1370 1393 return NULL; 1371 1394 } 1372 1395 memcpy(bssid, wdev->links[0].client.current_bss->pub.bssid, ETH_ALEN); 1373 - wdev_unlock(wdev); 1374 1396 1375 1397 memset(&sinfo, 0, sizeof(sinfo)); 1376 1398 1377 - wiphy_lock(&rdev->wiphy); 1378 1399 ret = rdev_get_station(rdev, dev, bssid, &sinfo); 1379 1400 wiphy_unlock(&rdev->wiphy); 1380 1401
+14 -45
net/wireless/wext-sme.c
··· 23 23 int err, i; 24 24 25 25 ASSERT_RTNL(); 26 - ASSERT_WDEV_LOCK(wdev); 26 + lockdep_assert_wiphy(wdev->wiphy); 27 27 28 28 if (!netif_running(wdev->netdev)) 29 29 return 0; ··· 87 87 return -EINVAL; 88 88 } 89 89 90 - wdev_lock(wdev); 91 - 92 90 if (wdev->conn) { 93 91 bool event = true; 94 92 95 - if (wdev->wext.connect.channel == chan) { 96 - err = 0; 97 - goto out; 98 - } 93 + if (wdev->wext.connect.channel == chan) 94 + return 0; 99 95 100 96 /* if SSID set, we'll try right again, avoid event */ 101 97 if (wdev->wext.connect.ssid_len) ··· 99 103 err = cfg80211_disconnect(rdev, dev, 100 104 WLAN_REASON_DEAUTH_LEAVING, event); 101 105 if (err) 102 - goto out; 106 + return err; 103 107 } 104 108 105 109 wdev->wext.connect.channel = chan; 106 - err = cfg80211_mgd_wext_connect(rdev, wdev); 107 - out: 108 - wdev_unlock(wdev); 109 - return err; 110 + return cfg80211_mgd_wext_connect(rdev, wdev); 110 111 } 111 112 112 113 int cfg80211_mgd_wext_giwfreq(struct net_device *dev, ··· 120 127 if (wdev->valid_links) 121 128 return -EOPNOTSUPP; 122 129 123 - wdev_lock(wdev); 124 130 if (wdev->links[0].client.current_bss) 125 131 chan = wdev->links[0].client.current_bss->pub.channel; 126 132 else if (wdev->wext.connect.channel) 127 133 chan = wdev->wext.connect.channel; 128 - wdev_unlock(wdev); 129 134 130 135 if (chan) { 131 136 freq->m = chan->center_freq; ··· 155 164 if (len > 0 && ssid[len - 1] == '\0') 156 165 len--; 157 166 158 - wdev_lock(wdev); 159 - 160 - err = 0; 161 - 162 167 if (wdev->conn) { 163 168 bool event = true; 164 169 165 170 if (wdev->wext.connect.ssid && len && 166 171 len == wdev->wext.connect.ssid_len && 167 172 memcmp(wdev->wext.connect.ssid, ssid, len) == 0) 168 - goto out; 173 + return 0; 169 174 170 175 /* if SSID set now, we'll try to connect, avoid event */ 171 176 if (len) ··· 169 182 err = cfg80211_disconnect(rdev, dev, 170 183 WLAN_REASON_DEAUTH_LEAVING, event); 171 184 if (err) 172 - goto out; 185 + return err; 173 186 } 174 187 175 188 wdev->wext.prev_bssid_valid = false; ··· 181 194 wdev->wext.connect.crypto.control_port_ethertype = 182 195 cpu_to_be16(ETH_P_PAE); 183 196 184 - err = cfg80211_mgd_wext_connect(rdev, wdev); 185 - out: 186 - wdev_unlock(wdev); 187 - return err; 197 + return cfg80211_mgd_wext_connect(rdev, wdev); 188 198 } 189 199 190 200 int cfg80211_mgd_wext_giwessid(struct net_device *dev, ··· 200 216 201 217 data->flags = 0; 202 218 203 - wdev_lock(wdev); 204 219 if (wdev->links[0].client.current_bss) { 205 220 const struct element *ssid_elem; 206 221 ··· 221 238 data->length = wdev->wext.connect.ssid_len; 222 239 memcpy(ssid, wdev->wext.connect.ssid, data->length); 223 240 } 224 - wdev_unlock(wdev); 225 241 226 242 return ret; 227 243 } ··· 245 263 if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) 246 264 bssid = NULL; 247 265 248 - wdev_lock(wdev); 249 - 250 266 if (wdev->conn) { 251 - err = 0; 252 267 /* both automatic */ 253 268 if (!bssid && !wdev->wext.connect.bssid) 254 - goto out; 269 + return 0; 255 270 256 271 /* fixed already - and no change */ 257 272 if (wdev->wext.connect.bssid && bssid && 258 273 ether_addr_equal(bssid, wdev->wext.connect.bssid)) 259 - goto out; 274 + return 0; 260 275 261 276 err = cfg80211_disconnect(rdev, dev, 262 277 WLAN_REASON_DEAUTH_LEAVING, false); 263 278 if (err) 264 - goto out; 279 + return err; 265 280 } 266 281 267 282 if (bssid) { ··· 267 288 } else 268 289 wdev->wext.connect.bssid = NULL; 269 290 270 - err = cfg80211_mgd_wext_connect(rdev, wdev); 271 - out: 272 - wdev_unlock(wdev); 273 - return err; 291 + return cfg80211_mgd_wext_connect(rdev, wdev); 274 292 } 275 293 276 294 int cfg80211_mgd_wext_giwap(struct net_device *dev, ··· 282 306 283 307 ap_addr->sa_family = ARPHRD_ETHER; 284 308 285 - wdev_lock(wdev); 286 - if (wdev->valid_links) { 287 - wdev_unlock(wdev); 309 + if (wdev->valid_links) 288 310 return -EOPNOTSUPP; 289 - } 311 + 290 312 if (wdev->links[0].client.current_bss) 291 313 memcpy(ap_addr->sa_data, 292 314 wdev->links[0].client.current_bss->pub.bssid, 293 315 ETH_ALEN); 294 316 else 295 317 eth_zero_addr(ap_addr->sa_data); 296 - wdev_unlock(wdev); 297 318 298 319 return 0; 299 320 } ··· 312 339 ie = NULL; 313 340 314 341 wiphy_lock(wdev->wiphy); 315 - wdev_lock(wdev); 316 342 317 343 /* no change */ 318 344 err = 0; ··· 342 370 /* userspace better not think we'll reconnect */ 343 371 err = 0; 344 372 out: 345 - wdev_unlock(wdev); 346 373 wiphy_unlock(wdev->wiphy); 347 374 return err; 348 375 } ··· 367 396 return -EINVAL; 368 397 369 398 wiphy_lock(&rdev->wiphy); 370 - wdev_lock(wdev); 371 399 switch (mlme->cmd) { 372 400 case IW_MLME_DEAUTH: 373 401 case IW_MLME_DISASSOC: ··· 376 406 err = -EOPNOTSUPP; 377 407 break; 378 408 } 379 - wdev_unlock(wdev); 380 409 wiphy_unlock(&rdev->wiphy); 381 410 382 411 return err;