Merge tag 'wireless-next-2022-08-26-v2' of git://git.kernel.org/pub/scm/linux/kernel...
authorDavid S. Miller <davem@davemloft.net>
Fri, 26 Aug 2022 10:56:55 +0000 (11:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 Aug 2022 10:56:55 +0000 (11:56 +0100)
Johannes berg says:

====================
Various updates:
 * rtw88: operation, locking, warning, and code style fixes
 * rtw89: small updates
 * cfg80211/mac80211: more EHT/MLO (802.11be, WiFi 7) work
 * brcmfmac: a couple of fixes
 * misc cleanups etc.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
1  2 
drivers/net/wireless/marvell/mwifiex/cfg80211.c
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
net/wireless/sme.c

index 134114ac1ac00ab9acf86e1e617f3c909df367c6,4f3bfdbe0d9d35aa0f7bd3b581180028eace7430..535995e8279f4ad2e82bbcb72a59d6a86d689dca
@@@ -1,8 -1,20 +1,8 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   * NXP Wireless LAN device driver: CFG80211
   *
   * Copyright 2011-2020 NXP
 - *
 - * This software file (the "File") is distributed by NXP
 - * under the terms of the GNU General Public License Version 2, June 1991
 - * (the "License").  You may use, redistribute and/or modify this File in
 - * accordance with the terms and conditions of the License, a copy of which
 - * is available by writing to the Free Software Foundation, Inc.,
 - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
 - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
 - *
 - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
 - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
 - * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
 - * this warranty disclaimer.
   */
  
  #include "cfg80211.h"
@@@ -142,7 -154,8 +142,8 @@@ static void *mwifiex_cfg80211_get_adapt
   */
  static int
  mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev,
-                        u8 key_index, bool pairwise, const u8 *mac_addr)
+                        int link_id, u8 key_index, bool pairwise,
+                        const u8 *mac_addr)
  {
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
        static const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
@@@ -431,7 -444,7 +432,7 @@@ mwifiex_cfg80211_set_power_mgmt(struct 
   */
  static int
  mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
-                                u8 key_index, bool unicast,
+                                int link_id, u8 key_index, bool unicast,
                                 bool multicast)
  {
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
   */
  static int
  mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev,
-                        u8 key_index, bool pairwise, const u8 *mac_addr,
-                        struct key_params *params)
+                        int link_id, u8 key_index, bool pairwise,
+                        const u8 *mac_addr, struct key_params *params)
  {
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
        struct mwifiex_wep_key *wep_key;
  static int
  mwifiex_cfg80211_set_default_mgmt_key(struct wiphy *wiphy,
                                      struct net_device *netdev,
+                                     int link_id,
                                      u8 key_index)
  {
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
index cb6d287f580dc24e39beef7a8626bf36acdf152b,1632a2654cc56f3887566c1a78f8e22d4422072d..2d09be6425d5b3ea82927c9c899484a78ecf4d84
@@@ -366,8 -366,9 +366,8 @@@ void rtw_cfg80211_ibss_indicate_connect
        int freq = (int)cur_network->network.configuration.ds_config;
        struct ieee80211_channel *chan;
  
 -      if (pwdev->iftype != NL80211_IFTYPE_ADHOC) {
 +      if (pwdev->iftype != NL80211_IFTYPE_ADHOC)
                return;
 -      }
  
        if (!rtw_cfg80211_check_bss(padapter)) {
                struct wlan_bssid_ex  *pnetwork = &(padapter->mlmeextpriv.mlmext_info.network);
@@@ -543,8 -544,9 +543,8 @@@ static int rtw_cfg80211_ap_set_encrypti
                        goto exit;
                }
  
 -              if (wep_key_len > 0) {
 +              if (wep_key_len > 0)
                        wep_key_len = wep_key_len <= 5 ? 5 : 13;
 -              }
  
                if (psecuritypriv->bWepDefaultKeyIdxSet == 0) {
                        /* wep default key has not been set, so use this key index as default key. */
                                memcpy(grpkey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
  
                                psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
 -                              if (param->u.crypt.key_len == 13) {
 +                              if (param->u.crypt.key_len == 13)
                                                psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
 -                              }
  
                        } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
                                psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
  
        }
  
 -      if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) /*  psk/802_1x */
 -      {
 -              if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
 -              {
 -                      if (param->u.crypt.set_tx == 1) /* pairwise key */
 -                      {
 +      if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /*  psk/802_1x */
 +              if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
 +                      if (param->u.crypt.set_tx == 1) { /* pairwise key */
                                memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
  
 -                              if (strcmp(param->u.crypt.alg, "WEP") == 0)
 -                              {
 +                              if (strcmp(param->u.crypt.alg, "WEP") == 0) {
                                        psta->dot118021XPrivacy = _WEP40_;
                                        if (param->u.crypt.key_len == 13)
 -                                      {
                                                psta->dot118021XPrivacy = _WEP104_;
 -                                      }
 -                              }
 -                              else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
 -                              {
 +                              } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
                                        psta->dot118021XPrivacy = _TKIP_;
  
                                        /* DEBUG_ERR("set key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len); */
  
                                        psecuritypriv->busetkipkey = true;
  
 -                              }
 -                              else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
 -                              {
 +                              } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
  
                                        psta->dot118021XPrivacy = _AES_;
 -                              }
 -                              else
 -                              {
 +                              } else {
                                        psta->dot118021XPrivacy = _NO_PRIVACY_;
                                }
  
  
                                psta->bpairwise_key_installed = true;
  
 -                      }
 -                      else/* group key??? */
 -                      {
 -                              if (strcmp(param->u.crypt.alg, "WEP") == 0)
 -                              {
 +                      } else { /* group key??? */
 +                              if (strcmp(param->u.crypt.alg, "WEP") == 0) {
                                        memcpy(grpkey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
  
                                        psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
                                        if (param->u.crypt.key_len == 13)
 -                                      {
                                                psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
 -                                      }
 -                              }
 -                              else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
 -                              {
 +                              } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
                                        psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
  
                                        memcpy(grpkey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
  
                                        psecuritypriv->busetkipkey = true;
  
 -                              }
 -                              else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
 -                              {
 +                              } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
                                        psecuritypriv->dot118021XGrpPrivacy = _AES_;
  
                                        memcpy(grpkey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
 -                              }
 -                              else
 -                              {
 +                              } else {
                                        psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
                                }
  
                                rtw_ap_set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx);
  
                                pbcmc_sta = rtw_get_bcmc_stainfo(padapter);
 -                              if (pbcmc_sta)
 -                              {
 +                              if (pbcmc_sta) {
                                        pbcmc_sta->ieee8021x_blocked = false;
                                        pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */
                                }
@@@ -719,16 -746,20 +719,16 @@@ static int rtw_cfg80211_set_encryption(
        param->u.crypt.err = 0;
        param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
  
 -      if (param_len < (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len)
 -      {
 +      if (param_len < (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len) {
                ret =  -EINVAL;
                goto exit;
        }
  
        if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
            param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
 -          param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
 -      {
 +          param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
                if (param->u.crypt.idx >= WEP_KEYS
 -                      || param->u.crypt.idx >= BIP_MAX_KEYID
 -              )
 -              {
 +                      || param->u.crypt.idx >= BIP_MAX_KEYID) {
                        ret = -EINVAL;
                        goto exit;
                }
        }
        }
  
 -      if (strcmp(param->u.crypt.alg, "WEP") == 0)
 -      {
 +      if (strcmp(param->u.crypt.alg, "WEP") == 0) {
                wep_key_idx = param->u.crypt.idx;
                wep_key_len = param->u.crypt.key_len;
  
 -              if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0))
 -              {
 +              if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) {
                        ret = -EINVAL;
                        goto exit;
                }
  
 -              if (psecuritypriv->bWepDefaultKeyIdxSet == 0)
 -              {
 +              if (psecuritypriv->bWepDefaultKeyIdxSet == 0) {
                        /* wep default key has not been set, so use this key index as default key. */
  
                        wep_key_len = wep_key_len <= 5 ? 5 : 13;
                        psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
                        psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
  
 -                      if (wep_key_len == 13)
 -                      {
 +                      if (wep_key_len == 13) {
                                psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
                                psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
                        }
                goto exit;
        }
  
 -      if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) /*  802_1x */
 -      {
 +      if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /*  802_1x */
                struct sta_info *psta, *pbcmc_sta;
                struct sta_priv *pstapriv = &padapter->stapriv;
  
 -              if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE) == true) /* sta mode */
 -              {
 +              if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE) == true) { /* sta mode */
                        psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
                        if (psta) {
                                /* Jeff: don't disable ieee8021x_blocked while clearing key */
  
  
                                if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) ||
 -                                              (padapter->securitypriv.ndisencryptstatus ==  Ndis802_11Encryption3Enabled))
 -                              {
 +                                              (padapter->securitypriv.ndisencryptstatus ==  Ndis802_11Encryption3Enabled)) {
                                        psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
                                }
  
 -                              if (param->u.crypt.set_tx == 1)/* pairwise key */
 -                              {
 +                              if (param->u.crypt.set_tx == 1) { /* pairwise key */
  
                                        memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
  
 -                                      if (strcmp(param->u.crypt.alg, "TKIP") == 0)/* set mic key */
 -                                      {
 +                                      if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */
                                                /* DEBUG_ERR(("\nset key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len)); */
                                                memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8);
                                                memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8);
                                        }
  
                                        rtw_setstakey_cmd(padapter, psta, true, true);
 -                              }
 -                              else/* group key */
 -                              {
 -                                      if (strcmp(param->u.crypt.alg, "TKIP") == 0 || strcmp(param->u.crypt.alg, "CCMP") == 0)
 -                                      {
 +                              } else { /* group key */
 +                                      if (strcmp(param->u.crypt.alg, "TKIP") == 0 || strcmp(param->u.crypt.alg, "CCMP") == 0) {
                                                memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
                                                memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8);
                                                memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8);
  
                                                padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx;
                                                rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1, true);
 -                                      }
 -                                      else if (strcmp(param->u.crypt.alg, "BIP") == 0)
 -                                      {
 +                                      } else if (strcmp(param->u.crypt.alg, "BIP") == 0) {
                                                /* save the IGTK key, length 16 bytes */
                                                memcpy(padapter->securitypriv.dot11wBIPKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
                                                /*
                        }
  
                        pbcmc_sta = rtw_get_bcmc_stainfo(padapter);
 -                      if (!pbcmc_sta)
 -                      {
 +                      if (!pbcmc_sta) {
                                /* DEBUG_ERR(("Set OID_802_11_ADD_KEY: bcmc stainfo is null\n")); */
 -                      }
 -                      else
 -                      {
 +                      } else {
                                /* Jeff: don't disable ieee8021x_blocked while clearing key */
                                if (strcmp(param->u.crypt.alg, "none") != 0)
                                        pbcmc_sta->ieee8021x_blocked = false;
  
                                if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) ||
 -                                              (padapter->securitypriv.ndisencryptstatus ==  Ndis802_11Encryption3Enabled))
 -                              {
 +                                              (padapter->securitypriv.ndisencryptstatus ==  Ndis802_11Encryption3Enabled)) {
                                        pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
                                }
                        }
 -              }
 -              else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) /* adhoc mode */
 -              {
 +              } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { /* adhoc mode */
                }
        }
  
@@@ -850,8 -901,8 +850,8 @@@ exit
  }
  
  static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
-                               u8 key_index, bool pairwise, const u8 *mac_addr,
-                               struct key_params *params)
+                               int link_id, u8 key_index, bool pairwise,
+                               const u8 *mac_addr, struct key_params *params)
  {
        char *alg_name;
        u32 param_len;
  
  
        if (!mac_addr || is_broadcast_ether_addr(mac_addr))
 -      {
                param->u.crypt.set_tx = 0; /* for wpa/wpa2 group key */
 -      } else {
 +      else
                param->u.crypt.set_tx = 1; /* for wpa/wpa2 pairwise key */
 -      }
  
        param->u.crypt.idx = key_index;
  
        if (params->seq_len && params->seq)
 -      {
                memcpy(param->u.crypt.seq, (u8 *)params->seq, params->seq_len);
 -      }
  
 -      if (params->key_len && params->key)
 -      {
 +      if (params->key_len && params->key) {
                param->u.crypt.key_len = params->key_len;
                memcpy(param->u.crypt.key, (u8 *)params->key, params->key_len);
        }
  
 -      if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
 -      {
 +      if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
                ret =  rtw_cfg80211_set_encryption(ndev, param, param_len);
 -      }
 -      else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
 -      {
 +      } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
                if (mac_addr)
                        memcpy(param->sta_addr, (void *)mac_addr, ETH_ALEN);
  
                ret = rtw_cfg80211_ap_set_encryption(ndev, param, param_len);
 -      }
 -        else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true
 -                || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)
 -        {
 +      } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true
 +                || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) {
                  ret =  rtw_cfg80211_set_encryption(ndev, param, param_len);
          }
  
@@@ -932,8 -993,8 +932,8 @@@ addkey_end
  }
  
  static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev,
-                               u8 key_index, bool pairwise, const u8 *mac_addr,
-                               void *cookie,
+                               int link_id, u8 key_index, bool pairwise,
+                               const u8 *mac_addr, void *cookie,
                                void (*callback)(void *cookie,
                                                 struct key_params*))
  {
  }
  
  static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
-                               u8 key_index, bool pairwise, const u8 *mac_addr)
+                               int link_id, u8 key_index, bool pairwise,
+                               const u8 *mac_addr)
  {
        struct adapter *padapter = rtw_netdev_priv(ndev);
        struct security_priv *psecuritypriv = &padapter->securitypriv;
  
 -      if (key_index == psecuritypriv->dot11PrivacyKeyIndex)
 -      {
 +      if (key_index == psecuritypriv->dot11PrivacyKeyIndex) {
                /* clear the flag of wep default key set. */
                psecuritypriv->bWepDefaultKeyIdxSet = 0;
        }
  }
  
  static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
-       struct net_device *ndev, u8 key_index
+       struct net_device *ndev, int link_id, u8 key_index
        , bool unicast, bool multicast
        )
  {
        struct adapter *padapter = rtw_netdev_priv(ndev);
        struct security_priv *psecuritypriv = &padapter->securitypriv;
  
 -      if ((key_index < WEP_KEYS) && ((psecuritypriv->dot11PrivacyAlgrthm == _WEP40_) || (psecuritypriv->dot11PrivacyAlgrthm == _WEP104_))) /* set wep default key */
 -      {
 +      if ((key_index < WEP_KEYS) && ((psecuritypriv->dot11PrivacyAlgrthm == _WEP40_) || (psecuritypriv->dot11PrivacyAlgrthm == _WEP104_))) { /* set wep default key */
                psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled;
  
                psecuritypriv->dot11PrivacyKeyIndex = key_index;
  
                psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
                psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
 -              if (psecuritypriv->dot11DefKeylen[key_index] == 13)
 -              {
 +              if (psecuritypriv->dot11DefKeylen[key_index] == 13) {
                        psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
                        psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
                }
@@@ -1007,7 -1072,9 +1008,7 @@@ static int cfg80211_rtw_get_station(str
  
        /* for infra./P2PClient mode */
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
 -              && check_fwstate(pmlmepriv, _FW_LINKED)
 -      )
 -      {
 +              && check_fwstate(pmlmepriv, _FW_LINKED)) {
                struct wlan_network  *cur_network = &(pmlmepriv->cur_network);
  
                if (memcmp((u8 *)mac, cur_network->network.mac_address, ETH_ALEN)) {
        if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)
   || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)
   || check_fwstate(pmlmepriv, WIFI_AP_STATE))
 -              && check_fwstate(pmlmepriv, _FW_LINKED)
 -      )
 -      {
 +              && check_fwstate(pmlmepriv, _FW_LINKED)) {
                /* TODO: should acquire station info... */
        }
  
@@@ -1053,7 -1122,8 +1054,7 @@@ static int cfg80211_rtw_change_iface(st
        struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
        int ret = 0;
  
 -      if (adapter_to_dvobj(padapter)->processing_dev_remove == true)
 -      {
 +      if (adapter_to_dvobj(padapter)->processing_dev_remove == true) {
                ret = -EPERM;
                goto exit;
        }
  
        old_type = rtw_wdev->iftype;
  
 -      if (old_type != type)
 -      {
 +      if (old_type != type) {
                pmlmeext->action_public_rxseq = 0xffff;
                pmlmeext->action_public_dialog_token = 0xff;
        }
  
        rtw_wdev->iftype = type;
  
 -      if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false)
 -      {
 +      if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false) {
                rtw_wdev->iftype = old_type;
                ret = -EPERM;
                goto exit;
@@@ -1159,7 -1231,9 +1160,7 @@@ void rtw_cfg80211_surveydone_event_call
  
                /* report network only if the current channel set contains the channel to which this network belongs */
                if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.configuration.ds_config) >= 0
 -                      && true == rtw_validate_ssid(&(pnetwork->network.ssid))
 -              )
 -              {
 +                      && true == rtw_validate_ssid(&(pnetwork->network.ssid))) {
                        /* ev =translate_scan(padapter, a, pnetwork, ev, stop); */
                        rtw_cfg80211_inform_bss(padapter, pnetwork);
                }
@@@ -1176,10 -1250,13 +1177,10 @@@ static int rtw_cfg80211_set_probe_req_w
        u8 *wps_ie;
        struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
  
 -      if (len > 0)
 -      {
 +      if (len > 0) {
                wps_ie = rtw_get_wps_ie(buf, len, NULL, &wps_ielen);
 -              if (wps_ie)
 -              {
 -                      if (pmlmepriv->wps_probe_req_ie)
 -                      {
 +              if (wps_ie) {
 +                      if (pmlmepriv->wps_probe_req_ie) {
                                pmlmepriv->wps_probe_req_ie_len = 0;
                                kfree(pmlmepriv->wps_probe_req_ie);
                                pmlmepriv->wps_probe_req_ie = NULL;
@@@ -1231,8 -1308,10 +1232,8 @@@ static int cfg80211_rtw_scan(struct wip
        pwdev_priv->scan_request = request;
        spin_unlock_bh(&pwdev_priv->scan_req_lock);
  
 -      if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
 -      {
 -              if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS|_FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true)
 -              {
 +      if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
 +              if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS|_FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) {
                        need_indicate_scan_done = true;
                        goto check_need_indicate_scan_done;
                }
                goto check_need_indicate_scan_done;
        }
  
 -      if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true)
 -      {
 -              static unsigned long lastscantime = 0;
 +      if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) {
 +              static unsigned long lastscantime;
                unsigned long passtime;
  
                passtime = jiffies_to_msecs(jiffies - lastscantime);
                lastscantime = jiffies;
 -              if (passtime > 12000)
 -              {
 +              if (passtime > 12000) {
                        need_indicate_scan_done = true;
                        goto check_need_indicate_scan_done;
                }
        } else if (request->n_channels <= 4) {
                for (j = request->n_channels - 1; j >= 0; j--)
                        for (i = 0; i < survey_times; i++)
 -              {
                        memcpy(&ch[j*survey_times+i], &ch[j], sizeof(struct rtw_ieee80211_channel));
 -              }
                _status = rtw_sitesurvey_cmd(padapter, ssid, RTW_SSID_SCAN_AMOUNT, ch, survey_times * request->n_channels);
        } else {
                _status = rtw_sitesurvey_cmd(padapter, ssid, RTW_SSID_SCAN_AMOUNT, NULL, 0);
  
  
        if (_status == false)
 -      {
                ret = -1;
 -      }
  
  check_need_indicate_scan_done:
        kfree(ssid);
 -      if (need_indicate_scan_done)
 -      {
 +      if (need_indicate_scan_done) {
                rtw_cfg80211_surveydone_event_callback(padapter);
                rtw_cfg80211_indicate_scan_done(padapter, false);
        }
@@@ -1339,7 -1425,9 +1340,7 @@@ static int rtw_cfg80211_set_wpa_version
  
  
        if (wpa_version & (NL80211_WPA_VERSION_1 | NL80211_WPA_VERSION_2))
 -      {
                psecuritypriv->ndisauthtype = Ndis802_11AuthModeWPAPSK;
 -      }
  
        return 0;
  
@@@ -1498,7 -1586,8 +1499,7 @@@ static int rtw_cfg80211_set_wpa_ie(stru
        if (pairwise_cipher == 0)
                pairwise_cipher = WPA_CIPHER_NONE;
  
 -      switch (group_cipher)
 -      {
 +      switch (group_cipher) {
                case WPA_CIPHER_NONE:
                        padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
                        padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
                        break;
        }
  
 -      switch (pairwise_cipher)
 -      {
 +      switch (pairwise_cipher) {
                case WPA_CIPHER_NONE:
                        padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
                        padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
@@@ -1642,7 -1732,8 +1643,7 @@@ static int cfg80211_rtw_leave_ibss(stru
  
                rtw_wdev->iftype = NL80211_IFTYPE_STATION;
  
 -              if (rtw_set_802_11_infrastructure_mode(padapter, Ndis802_11Infrastructure) == false)
 -              {
 +              if (rtw_set_802_11_infrastructure_mode(padapter, Ndis802_11Infrastructure) == false) {
                        rtw_wdev->iftype = old_type;
                        ret = -EPERM;
                        goto leave_ibss;
@@@ -1702,8 -1793,9 +1703,8 @@@ static int cfg80211_rtw_connect(struct 
                ret = -EBUSY;
                goto exit;
        }
 -      if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) {
 +      if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
                rtw_scan_abort(padapter);
 -      }
  
        psecuritypriv->ndisencryptstatus = Ndis802_11EncryptionDisabled;
        psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
@@@ -2197,8 -2289,9 +2198,8 @@@ static int rtw_cfg80211_add_monitor_if(
        mon_ndev->ieee80211_ptr = mon_wdev;
  
        ret = cfg80211_register_netdevice(mon_ndev);
 -      if (ret) {
 +      if (ret)
                goto out;
 -      }
  
        *ndev = pwdev_priv->pmon_ndev = mon_ndev;
        memcpy(pwdev_priv->ifname_mon, name, IFNAMSIZ+1);
@@@ -2311,10 -2404,11 +2312,10 @@@ static int rtw_add_beacon(struct adapte
        rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, P2P_OUI, 4);
        rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, WFD_OUI, 4);
  
 -      if (rtw_check_beacon_data(adapter, pbuf,  len) == _SUCCESS) {
 +      if (rtw_check_beacon_data(adapter, pbuf,  len) == _SUCCESS)
                ret = 0;
 -      } else {
 +      else
                ret = -EINVAL;
 -      }
  
  
        kfree(pbuf);
diff --combined net/wireless/sme.c
index 27fb2a0c405242aae74c67724326a61ebc92089f,0a5c95631f789531450ea79001a3e41315ec73e2..d513536617bd9ea5161f0bfa0681ab01817d588d
@@@ -747,6 -747,9 +747,9 @@@ void __cfg80211_connect_result(struct n
                        if (WARN_ON(!cr->links[link].addr))
                                goto out;
                }
+               if (WARN_ON(wdev->connect_keys))
+                       goto out;
        }
  
        wdev->unprot_beacon_reported = 0;
  #endif
  
        if (cr->status == WLAN_STATUS_SUCCESS) {
 -              for_each_valid_link(cr, link) {
 -                      if (WARN_ON_ONCE(!cr->links[link].bss))
 -                              break;
 +              if (!wiphy_to_rdev(wdev->wiphy)->ops->connect) {
 +                      for_each_valid_link(cr, link) {
 +                              if (WARN_ON_ONCE(!cr->links[link].bss))
 +                                      break;
 +                      }
                }
  
                for_each_valid_link(cr, link) {
@@@ -1325,7 -1326,7 +1328,7 @@@ void __cfg80211_disconnected(struct net
                            NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT))
                        max_key_idx = 7;
                for (i = 0; i <= max_key_idx; i++)
-                       rdev_del_key(rdev, dev, i, false, NULL);
+                       rdev_del_key(rdev, dev, -1, i, false, NULL);
        }
  
        rdev_set_qos_map(rdev, dev, NULL);