Commit 9216c517 authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

staging: rtl8723au: Fix up some random bit-flag handling

Randomly mixing true/false/_FAIL/0/1 is a recipe for disaster
Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3e3a1adf
...@@ -755,7 +755,7 @@ int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key) ...@@ -755,7 +755,7 @@ int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key)
} }
/* jeff: set this becasue at least sw key is ready */ /* jeff: set this becasue at least sw key is ready */
padapter->securitypriv.busetkipkey = true; padapter->securitypriv.busetkipkey = 1;
res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); res = rtw_enqueue_cmd23a(pcmdpriv, ph2c);
......
...@@ -1027,9 +1027,8 @@ rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, ...@@ -1027,9 +1027,8 @@ rtw_joinbss_update_stainfo(struct rtw_adapter *padapter,
/* security related */ /* security related */
if (padapter->securitypriv.dot11AuthAlgrthm == if (padapter->securitypriv.dot11AuthAlgrthm ==
dot11AuthAlgrthm_8021X) { dot11AuthAlgrthm_8021X) {
padapter->securitypriv.binstallGrpkey = false; padapter->securitypriv.binstallGrpkey = 0;
padapter->securitypriv.busetkipkey = false; padapter->securitypriv.busetkipkey = 0;
padapter->securitypriv.bgrpkey_handshake = false;
psta->ieee8021x_blocked = true; psta->ieee8021x_blocked = true;
psta->dot118021XPrivacy = psta->dot118021XPrivacy =
......
...@@ -306,7 +306,7 @@ static u8 PS_RDY_CHECK(struct rtw_adapter * padapter) ...@@ -306,7 +306,7 @@ static u8 PS_RDY_CHECK(struct rtw_adapter * padapter)
if (pwrpriv->bInSuspend) if (pwrpriv->bInSuspend)
return false; return false;
if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X &&
padapter->securitypriv.binstallGrpkey == false) { !padapter->securitypriv.binstallGrpkey) {
DBG_8723A("Group handshake still in progress !!!\n"); DBG_8723A("Group handshake still in progress !!!\n");
return false; return false;
} }
......
...@@ -313,7 +313,7 @@ int recvframe_chkmic(struct rtw_adapter *adapter, ...@@ -313,7 +313,7 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
("\n recvframe_chkmic: bcmc key\n")); ("\n recvframe_chkmic: bcmc key\n"));
if (psecuritypriv->binstallGrpkey == false) { if (!psecuritypriv->binstallGrpkey) {
res = _FAIL; res = _FAIL;
RT_TRACE(_module_rtl871x_recv_c_, RT_TRACE(_module_rtl871x_recv_c_,
_drv_err_, _drv_err_,
...@@ -442,9 +442,9 @@ int recvframe_chkmic(struct rtw_adapter *adapter, ...@@ -442,9 +442,9 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
res = _FAIL; res = _FAIL;
} else { } else {
/* mic checked ok */ /* mic checked ok */
if ((psecuritypriv->bcheck_grpkey == false) && if (!psecuritypriv->bcheck_grpkey &&
(is_multicast_ether_addr(prxattrib->ra))) { is_multicast_ether_addr(prxattrib->ra)) {
psecuritypriv->bcheck_grpkey = true; psecuritypriv->bcheck_grpkey = 1;
RT_TRACE(_module_rtl871x_recv_c_, RT_TRACE(_module_rtl871x_recv_c_,
_drv_err_, _drv_err_,
("psecuritypriv->bcheck_grp" ("psecuritypriv->bcheck_grp"
...@@ -507,7 +507,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, ...@@ -507,7 +507,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter,
} }
if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0))) { if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0))) {
psecuritypriv->hw_decrypted = false; psecuritypriv->hw_decrypted = 0;
switch (prxattrib->encrypt) { switch (prxattrib->encrypt) {
case _WEP40_: case _WEP40_:
case _WEP104_: case _WEP104_:
...@@ -525,7 +525,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, ...@@ -525,7 +525,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter,
} else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 && } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 &&
(psecuritypriv->busetkipkey == 1 || (psecuritypriv->busetkipkey == 1 ||
prxattrib->encrypt != _TKIP_)) { prxattrib->encrypt != _TKIP_)) {
psecuritypriv->hw_decrypted = true; psecuritypriv->hw_decrypted = 1;
} }
if (res == _FAIL) { if (res == _FAIL) {
......
...@@ -744,7 +744,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, ...@@ -744,7 +744,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
if (stainfo!= NULL) { if (stainfo!= NULL) {
if (is_multicast_ether_addr(prxattrib->ra)) { if (is_multicast_ether_addr(prxattrib->ra)) {
if (psecuritypriv->binstallGrpkey == false) { if (psecuritypriv->binstallGrpkey == 0) {
res = _FAIL; res = _FAIL;
DBG_8723A("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); DBG_8723A("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__);
goto exit; goto exit;
...@@ -1645,7 +1645,7 @@ void rtw_use_tkipkey_handler23a(void *FunctionContext) ...@@ -1645,7 +1645,7 @@ void rtw_use_tkipkey_handler23a(void *FunctionContext)
struct rtw_adapter *padapter = (struct rtw_adapter *)FunctionContext; struct rtw_adapter *padapter = (struct rtw_adapter *)FunctionContext;
RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler23a ^^^\n")); RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler23a ^^^\n"));
padapter->securitypriv.busetkipkey = true; padapter->securitypriv.busetkipkey = 1;
RT_TRACE(_module_rtl871x_security_c_, _drv_err_, RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
("^^^rtw_use_tkipkey_handler23a padapter->securitypriv.busetkipkey =%d^^^\n", ("^^^rtw_use_tkipkey_handler23a padapter->securitypriv.busetkipkey =%d^^^\n",
padapter->securitypriv.busetkipkey)); padapter->securitypriv.busetkipkey));
......
...@@ -604,10 +604,10 @@ static int update_attrib(struct rtw_adapter *padapter, ...@@ -604,10 +604,10 @@ static int update_attrib(struct rtw_adapter *padapter,
pattrib->iv_len = 8; pattrib->iv_len = 8;
pattrib->icv_len = 4; pattrib->icv_len = 4;
if (padapter->securitypriv.busetkipkey == _FAIL) { if (!padapter->securitypriv.busetkipkey) {
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
("\npadapter->securitypriv.busetkip" ("\npadapter->securitypriv.busetkip"
"key(%d) == _FAIL drop packet\n", "key(%d) == false drop packet\n",
padapter->securitypriv.busetkipkey)); padapter->securitypriv.busetkipkey));
res = _FAIL; res = _FAIL;
goto exit; goto exit;
...@@ -630,7 +630,7 @@ static int update_attrib(struct rtw_adapter *padapter, ...@@ -630,7 +630,7 @@ static int update_attrib(struct rtw_adapter *padapter,
RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
("update_attrib: encrypt =%d\n", pattrib->encrypt)); ("update_attrib: encrypt =%d\n", pattrib->encrypt));
if (pattrib->encrypt && psecuritypriv->hw_decrypted == false) { if (pattrib->encrypt && !psecuritypriv->hw_decrypted) {
pattrib->bswenc = true; pattrib->bswenc = true;
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
("update_attrib: encrypt =%d bswenc = true\n", ("update_attrib: encrypt =%d bswenc = true\n",
......
...@@ -139,11 +139,10 @@ struct security_priv { ...@@ -139,11 +139,10 @@ struct security_priv {
u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */ u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */
int wps_ie_len; int wps_ie_len;
u8 binstallGrpkey; unsigned int binstallGrpkey:1;
u8 busetkipkey; unsigned int busetkipkey:1;
u8 bcheck_grpkey; unsigned int bcheck_grpkey:1;
u8 bgrpkey_handshake; unsigned int hw_decrypted:1;
s32 hw_decrypted;
u32 ndisauthtype; /* enum ndis_802_11_auth_mode */ u32 ndisauthtype; /* enum ndis_802_11_auth_mode */
u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */ u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */
struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */ struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */
......
...@@ -689,7 +689,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -689,7 +689,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
idx].skey, idx].skey,
&param->u.crypt.key[24], 8); &param->u.crypt.key[24], 8);
psecuritypriv->busetkipkey = true; psecuritypriv->busetkipkey = 1;
} else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
DBG_8723A("%s, set group_key, CCMP\n", DBG_8723A("%s, set group_key, CCMP\n",
...@@ -712,7 +712,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -712,7 +712,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx;
psecuritypriv->binstallGrpkey = true; psecuritypriv->binstallGrpkey = 1;
psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot11PrivacyAlgrthm =
psecuritypriv->dot118021XGrpPrivacy; psecuritypriv->dot118021XGrpPrivacy;
...@@ -767,7 +767,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -767,7 +767,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
memcpy(psta->dot11tkiprxmickey.skey, memcpy(psta->dot11tkiprxmickey.skey,
&param->u.crypt.key[24], 8); &param->u.crypt.key[24], 8);
psecuritypriv->busetkipkey = true; psecuritypriv->busetkipkey = 1;
} else if (!strcmp(param->u.crypt.alg, "CCMP")) { } else if (!strcmp(param->u.crypt.alg, "CCMP")) {
...@@ -831,7 +831,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -831,7 +831,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
skey, &param->u.crypt.key[24], skey, &param->u.crypt.key[24],
8); 8);
psecuritypriv->busetkipkey = true; psecuritypriv->busetkipkey = 1;
} else if (!strcmp(param->u.crypt.alg, "CCMP")) { } else if (!strcmp(param->u.crypt.alg, "CCMP")) {
psecuritypriv->dot118021XGrpPrivacy = psecuritypriv->dot118021XGrpPrivacy =
...@@ -852,7 +852,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -852,7 +852,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psecuritypriv->dot118021XGrpKeyid = psecuritypriv->dot118021XGrpKeyid =
param->u.crypt.idx; param->u.crypt.idx;
psecuritypriv->binstallGrpkey = true; psecuritypriv->binstallGrpkey = 1;
psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot11PrivacyAlgrthm =
psecuritypriv->dot118021XGrpPrivacy; psecuritypriv->dot118021XGrpPrivacy;
...@@ -1003,7 +1003,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, ...@@ -1003,7 +1003,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
8); 8);
padapter->securitypriv. padapter->securitypriv.
busetkipkey = false; busetkipkey = 0;
} }
DBG_8723A(" ~~~~set sta key:unicastkey\n"); DBG_8723A(" ~~~~set sta key:unicastkey\n");
...@@ -1029,7 +1029,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, ...@@ -1029,7 +1029,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
skey, &param->u.crypt.key[24], skey, &param->u.crypt.key[24],
8); 8);
padapter->securitypriv.binstallGrpkey = padapter->securitypriv.binstallGrpkey =
true; 1;
/* DEBUG_ERR((" param->u.crypt.key_len" /* DEBUG_ERR((" param->u.crypt.key_len"
"=%d\n", param->u.crypt.key_len)); */ "=%d\n", param->u.crypt.key_len)); */
DBG_8723A DBG_8723A
......
...@@ -401,7 +401,7 @@ static int rtw_init_default_value(struct rtw_adapter *padapter) ...@@ -401,7 +401,7 @@ static int rtw_init_default_value(struct rtw_adapter *padapter)
pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */ pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */
/* security_priv */ /* security_priv */
psecuritypriv->binstallGrpkey = _FAIL; psecuritypriv->binstallGrpkey = 0;
/* open system */ /* open system */
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment