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

Configure Feed

Select the types of activity you want to include in your feed.

staging: r8188eu: use proper type for second argiment of rtw_(aes|tkip|wep)_(decrypt|encrypt)

rtw_aes_decrypt, rtw_tkip_decrypt, rtw_wep_decrypt, rtw_aes_encrypt,
rtw_tkip_encrypt, rtw_wep_encrypt are takes (u8 *) second argiment and
always uses it as (struct recv_frame *) or (struct xmit_frame *).
This is causes a lot of unnecessary type casts
and complicates refactoring.

Signed-off-by: Ivan Safonov <insafonov@gmail.com>
Link: https://lore.kernel.org/r/20200726210246.68633-1-insafonov@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ivan Safonov and committed by
Greg Kroah-Hartman
01713f0d 8750d02d

+38 -38
+1 -1
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
··· 870 870 871 871 pattrib->last_txcmdsz = pattrib->pktlen; 872 872 873 - rtw_wep_encrypt(padapter, (u8 *)pmgntframe); 873 + rtw_wep_encrypt(padapter, pmgntframe); 874 874 DBG_88E("%s\n", __func__); 875 875 dump_mgntframe(padapter, pmgntframe); 876 876 }
+3 -3
drivers/staging/rtl8188eu/core/rtw_recv.c
··· 384 384 switch (prxattrib->encrypt) { 385 385 case _WEP40_: 386 386 case _WEP104_: 387 - res = rtw_wep_decrypt(padapter, (u8 *)precv_frame); 387 + res = rtw_wep_decrypt(padapter, precv_frame); 388 388 break; 389 389 case _TKIP_: 390 - res = rtw_tkip_decrypt(padapter, (u8 *)precv_frame); 390 + res = rtw_tkip_decrypt(padapter, precv_frame); 391 391 break; 392 392 case _AES_: 393 - res = rtw_aes_decrypt(padapter, (u8 *)precv_frame); 393 + res = rtw_aes_decrypt(padapter, precv_frame); 394 394 break; 395 395 default: 396 396 break;
+25 -25
drivers/staging/rtl8188eu/core/rtw_security.c
··· 129 129 /* 130 130 Need to consider the fragment situation 131 131 */ 132 - void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) 132 + void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) 133 133 { 134 134 int curfragnum, length; 135 135 u8 *pframe; 136 136 u8 hw_hdr_offset = 0; 137 - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; 137 + struct pkt_attrib *pattrib = &pxmitframe->attrib; 138 138 struct security_priv *psecuritypriv = &padapter->securitypriv; 139 139 struct xmit_priv *pxmitpriv = &padapter->xmitpriv; 140 140 const int keyindex = psecuritypriv->dot11PrivacyKeyIndex; ··· 142 142 struct sk_buff *skb; 143 143 struct lib80211_crypto_ops *crypto_ops; 144 144 145 - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) 145 + if (pxmitframe->buf_addr == NULL) 146 146 return; 147 147 148 148 if ((pattrib->encrypt != _WEP40_) && (pattrib->encrypt != _WEP104_)) 149 149 return; 150 150 151 151 hw_hdr_offset = TXDESC_SIZE + 152 - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); 152 + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); 153 153 154 - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; 154 + pframe = pxmitframe->buf_addr + hw_hdr_offset; 155 155 156 156 crypto_ops = lib80211_get_crypto_ops("WEP"); 157 157 ··· 198 198 crypto_ops->deinit(crypto_private); 199 199 } 200 200 201 - int rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) 201 + int rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe) 202 202 { 203 - struct rx_pkt_attrib *prxattrib = &(((struct recv_frame *)precvframe)->attrib); 203 + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; 204 204 205 205 if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { 206 206 struct security_priv *psecuritypriv = &padapter->securitypriv; 207 - struct sk_buff *skb = ((struct recv_frame *)precvframe)->pkt; 207 + struct sk_buff *skb = precvframe->pkt; 208 208 u8 *pframe = skb->data; 209 209 void *crypto_private = NULL; 210 210 int status = _SUCCESS; ··· 572 572 } 573 573 574 574 /* The hlen isn't include the IV */ 575 - u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) 575 + u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) 576 576 { /* exclude ICV */ 577 577 u16 pnl; 578 578 u32 pnh; ··· 586 586 u8 *pframe, *payload, *iv, *prwskey; 587 587 union pn48 dot11txpn; 588 588 struct sta_info *stainfo; 589 - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; 589 + struct pkt_attrib *pattrib = &pxmitframe->attrib; 590 590 struct security_priv *psecuritypriv = &padapter->securitypriv; 591 591 struct xmit_priv *pxmitpriv = &padapter->xmitpriv; 592 592 u32 res = _SUCCESS; 593 593 594 - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) 594 + if (pxmitframe->buf_addr == NULL) 595 595 return _FAIL; 596 596 597 597 hw_hdr_offset = TXDESC_SIZE + 598 - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); 599 - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; 598 + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); 599 + pframe = pxmitframe->buf_addr + hw_hdr_offset; 600 600 /* 4 start to encrypt each fragment */ 601 601 if (pattrib->encrypt == _TKIP_) { 602 602 if (pattrib->psta) ··· 653 653 } 654 654 655 655 /* The hlen isn't include the IV */ 656 - u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) 656 + u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe) 657 657 { /* exclude ICV */ 658 658 u16 pnl; 659 659 u32 pnh; ··· 666 666 u8 *pframe, *payload, *iv, *prwskey; 667 667 union pn48 dot11txpn; 668 668 struct sta_info *stainfo; 669 - struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; 669 + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; 670 670 struct security_priv *psecuritypriv = &padapter->securitypriv; 671 671 u32 res = _SUCCESS; 672 672 673 673 674 - pframe = (unsigned char *)((struct recv_frame *)precvframe)->pkt->data; 674 + pframe = (unsigned char *)precvframe->pkt->data; 675 675 676 676 /* 4 start to decrypt recvframe */ 677 677 if (prxattrib->encrypt == _TKIP_) { ··· 691 691 692 692 iv = pframe + prxattrib->hdrlen; 693 693 payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; 694 - length = ((struct recv_frame *)precvframe)->pkt->len - prxattrib->hdrlen - prxattrib->iv_len; 694 + length = precvframe->pkt->len - prxattrib->hdrlen - prxattrib->iv_len; 695 695 696 696 GET_TKIP_PN(iv, dot11txpn); 697 697 ··· 1214 1214 return _SUCCESS; 1215 1215 } 1216 1216 1217 - u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) 1217 + u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) 1218 1218 { /* exclude ICV */ 1219 1219 1220 1220 /*static*/ ··· 1225 1225 u8 *pframe, *prwskey; /* *payload,*iv */ 1226 1226 u8 hw_hdr_offset = 0; 1227 1227 struct sta_info *stainfo; 1228 - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; 1228 + struct pkt_attrib *pattrib = &pxmitframe->attrib; 1229 1229 struct security_priv *psecuritypriv = &padapter->securitypriv; 1230 1230 struct xmit_priv *pxmitpriv = &padapter->xmitpriv; 1231 1231 1232 1232 /* uint offset = 0; */ 1233 1233 u32 res = _SUCCESS; 1234 1234 1235 - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) 1235 + if (pxmitframe->buf_addr == NULL) 1236 1236 return _FAIL; 1237 1237 1238 1238 hw_hdr_offset = TXDESC_SIZE + 1239 - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); 1239 + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); 1240 1240 1241 - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; 1241 + pframe = pxmitframe->buf_addr + hw_hdr_offset; 1242 1242 1243 1243 /* 4 start to encrypt each fragment */ 1244 1244 if (pattrib->encrypt == _AES_) { ··· 1276 1276 return res; 1277 1277 } 1278 1278 1279 - u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) 1279 + u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe) 1280 1280 { 1281 - struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; 1281 + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; 1282 1282 u32 res = _SUCCESS; 1283 1283 1284 1284 /* 4 start to encrypt each fragment */ ··· 1288 1288 if (stainfo != NULL) { 1289 1289 int key_idx; 1290 1290 const int key_length = 16, iv_len = 8, icv_len = 8; 1291 - struct sk_buff *skb = ((struct recv_frame *)precvframe)->pkt; 1291 + struct sk_buff *skb = precvframe->pkt; 1292 1292 void *crypto_private = NULL; 1293 1293 u8 *key, *pframe = skb->data; 1294 1294 struct lib80211_crypto_ops *crypto_ops = lib80211_get_crypto_ops("CCMP");
+3 -3
drivers/staging/rtl8188eu/core/rtw_xmit.c
··· 713 713 switch (pattrib->encrypt) { 714 714 case _WEP40_: 715 715 case _WEP104_: 716 - rtw_wep_encrypt(padapter, (u8 *)pxmitframe); 716 + rtw_wep_encrypt(padapter, pxmitframe); 717 717 break; 718 718 case _TKIP_: 719 - rtw_tkip_encrypt(padapter, (u8 *)pxmitframe); 719 + rtw_tkip_encrypt(padapter, pxmitframe); 720 720 break; 721 721 case _AES_: 722 - rtw_aes_encrypt(padapter, (u8 *)pxmitframe); 722 + rtw_aes_encrypt(padapter, pxmitframe); 723 723 break; 724 724 default: 725 725 break;
+6 -6
drivers/staging/rtl8188eu/include/rtw_security.h
··· 292 292 void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst); 293 293 void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, 294 294 u8 *Miccode, u8 priority); 295 - u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe); 296 - u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe); 297 - void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe); 298 - u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe); 299 - u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe); 300 - int rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe); 295 + u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); 296 + u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); 297 + void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); 298 + u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe); 299 + u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe); 300 + int rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe); 301 301 302 302 #endif /* __RTL871X_SECURITY_H_ */