Commit c3cc7593 authored by M. Vefa Bicakci's avatar M. Vefa Bicakci Committed by Greg Kroah-Hartman

staging: rtl8723au: Reorganize a few functions to remove indentation

Prior to this commit, functions rtw_tkip_encrypt23a and rtw_tkip_decrypt23a had
large if blocks which contained the majority of the logic in the functions.

Rework these functions so that if the negated version of the aforementioned if
blocks' conditions are true, we return from the function with _FAIL, as
expected by the calling code.

This lets us remove two levels of indentation from the functions in
question, making them more readable.
Signed-off-by: default avatarM. Vefa Bicakci <m.v.b@runbox.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a2390239
...@@ -615,14 +615,16 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, ...@@ -615,14 +615,16 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
int res = _SUCCESS; int res = _SUCCESS;
if (pattrib->encrypt != WLAN_CIPHER_SUITE_TKIP)
return _FAIL;
if (!pxmitframe->buf_addr) if (!pxmitframe->buf_addr)
return _FAIL; return _FAIL;
hw_hdr_offset = TXDESC_OFFSET; hw_hdr_offset = TXDESC_OFFSET;
pframe = pxmitframe->buf_addr + hw_hdr_offset; pframe = pxmitframe->buf_addr + hw_hdr_offset;
/* 4 start to encrypt each fragment */
if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
if (pattrib->psta) if (pattrib->psta)
stainfo = pattrib->psta; stainfo = pattrib->psta;
else { else {
...@@ -631,16 +633,21 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, ...@@ -631,16 +633,21 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
&pattrib->ra[0]); &pattrib->ra[0]);
} }
if (stainfo != NULL) { if (stainfo == NULL) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
if (!(stainfo->state & _FW_LINKED)) { "rtw_tkip_encrypt23a: stainfo == NULL!!!\n");
DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state); DBG_8723A("%s, psta == NUL\n", __func__);
return _FAIL; return _FAIL;
} }
RT_TRACE(_module_rtl871x_security_c_, _drv_err_, RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
"rtw_tkip_encrypt23a: stainfo!= NULL!!!\n"); "rtw_tkip_encrypt23a: stainfo!= NULL!!!\n");
if (!(stainfo->state & _FW_LINKED)) {
DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state);
return _FAIL;
}
if (is_multicast_ether_addr(pattrib->ra)) if (is_multicast_ether_addr(pattrib->ra))
prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
else else
...@@ -648,6 +655,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, ...@@ -648,6 +655,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
prwskeylen = 16; prwskeylen = 16;
/* 4 start to encrypt each fragment */
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
iv = pframe + pattrib->hdrlen; iv = pframe + pattrib->hdrlen;
payload = pframe + pattrib->iv_len + pattrib->hdrlen; payload = pframe + pattrib->iv_len + pattrib->hdrlen;
...@@ -693,15 +701,6 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, ...@@ -693,15 +701,6 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
} }
} }
} else {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
"rtw_tkip_encrypt23a: stainfo == NULL!!!\n");
DBG_8723A("%s, psta == NUL\n", __func__);
res = _FAIL;
}
}
return res; return res;
} }
...@@ -725,15 +724,20 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, ...@@ -725,15 +724,20 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
struct sk_buff *skb = precvframe->pkt; struct sk_buff *skb = precvframe->pkt;
int res = _SUCCESS; int res = _SUCCESS;
pframe = skb->data; if (prxattrib->encrypt != WLAN_CIPHER_SUITE_TKIP)
return _FAIL;
/* 4 start to decrypt recvframe */ pframe = skb->data;
if (prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
stainfo = rtw_get_stainfo23a(&padapter->stapriv, stainfo = rtw_get_stainfo23a(&padapter->stapriv,
&prxattrib->ta[0]); &prxattrib->ta[0]);
if (stainfo != NULL) { if (stainfo == NULL) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
"rtw_tkip_decrypt23a: stainfo == NULL!!!\n");
return _FAIL;
}
/* 4 start to decrypt recvframe */
if (is_multicast_ether_addr(prxattrib->ra)) { if (is_multicast_ether_addr(prxattrib->ra)) {
if (psecuritypriv->binstallGrpkey == 0) { if (psecuritypriv->binstallGrpkey == 0) {
res = _FAIL; res = _FAIL;
...@@ -777,12 +781,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, ...@@ -777,12 +781,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
crc[0], payload[length - 4]); crc[0], payload[length - 4]);
res = _FAIL; res = _FAIL;
} }
} else {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
"rtw_tkip_decrypt23a: stainfo == NULL!!!\n");
res = _FAIL;
}
}
exit: exit:
return res; return res;
} }
......
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