* [PATCH v2] staging: rtl8723bs: fix lines exceeding 100 columns in rtw_security.c
@ 2026-09-15 7:29 Rareș-Mihai Vladu
2026-09-15 7:58 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Rareș-Mihai Vladu @ 2026-09-15 7:29 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel, lkp, Rareș-Mihai Vladu
Reformat long lines in rtw_security.c to fit within the 100-column
limit by splitting function arguments, expressions, and moving
Signed-off-by: Rareș-Mihai Vladu <vladurares@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 94 +++++++++++++------
1 file changed, 66 insertions(+), 28 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 2217cffac..dc9ac335d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -34,7 +34,8 @@ const char *security_type_str(u8 value)
/* Need to consider the fragment situation */
void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
-{ /* exclude ICV */
+{
+ /* exclude ICV */
union {
__le32 f0;
unsigned char f1[4];
@@ -64,12 +65,17 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
iv = pframe + pattrib->hdrlen;
memcpy(&wepkey[0], iv, 3);
- memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength);
+ int idx = psecuritypriv->dot11PrivacyKeyIndex;
+
+ memcpy(&wepkey[3],
+ &psecuritypriv->dot11DefKey[idx].skey[0],
+ keylength);
payload = pframe + pattrib->iv_len + pattrib->hdrlen;
if ((curfragnum + 1) == pattrib->nr_frags) { /* the last fragment */
- length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
+ length = pattrib->last_txcmdsz - pattrib->hdrlen -
+ pattrib->iv_len - pattrib->icv_len;
crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
@@ -78,7 +84,8 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
arc4_crypt(ctx, payload + length, crc.f1, 4);
} else {
- length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
+ length = pxmitpriv->frag_len - pattrib->hdrlen -
+ pattrib->iv_len - pattrib->icv_len;
crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
arc4_setkey(ctx, wepkey, 3 + keylength);
arc4_crypt(ctx, payload, payload, length);
@@ -112,9 +119,16 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
keyindex = prxattrib->key_index;
keylength = psecuritypriv->dot11DefKeylen[keyindex];
memcpy(&wepkey[0], iv, 3);
- /* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */
- memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength);
- length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
+ /*
+ * memcpy(&wepkey[3],
+ * &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0],
+ * keylength);
+ */
+ memcpy(&wepkey[3],
+ &psecuritypriv->dot11DefKey[keyindex].skey[0],
+ keylength);
+ length = ((union recv_frame *)precvframe)->u.hdr.len -
+ prxattrib->hdrlen - prxattrib->iv_len;
payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
@@ -157,7 +171,8 @@ void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b)
pmicdata->L ^= pmicdata->M;
pmicdata->R ^= ROL32(pmicdata->L, 17);
pmicdata->L += pmicdata->R;
- pmicdata->R ^= ((pmicdata->L & 0xff00ff00) >> 8) | ((pmicdata->L & 0x00ff00ff) << 8);
+ pmicdata->R ^= ((pmicdata->L & 0xff00ff00) >> 8) |
+ ((pmicdata->L & 0x00ff00ff) << 8);
pmicdata->L += pmicdata->R;
pmicdata->R ^= ROL32(pmicdata->L, 3);
pmicdata->L += pmicdata->R;
@@ -418,7 +433,8 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
/* The hlen isn't include the IV */
u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
-{ /* exclude ICV */
+{
+ /* exclude ICV */
u16 pnl;
u32 pnh;
u8 rc4key[16];
@@ -467,7 +483,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl);
if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */
- length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
+ length = pattrib->last_txcmdsz - pattrib->hdrlen -
+ pattrib->iv_len - pattrib->icv_len;
crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
arc4_setkey(ctx, rc4key, 16);
@@ -475,7 +492,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
arc4_crypt(ctx, payload + length, crc.f1, 4);
} else {
- length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
+ length = pxmitpriv->frag_len - pattrib->hdrlen -
+ pattrib->iv_len - pattrib->icv_len;
crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length));
arc4_setkey(ctx, rc4key, 16);
@@ -491,7 +509,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
/* The hlen isn't include the IV */
u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
-{ /* exclude ICV */
+{
+ /* exclude ICV */
u16 pnl;
u32 pnh;
u8 rc4key[16];
@@ -536,7 +555,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
if (jiffies_to_msecs(jiffies - start) > 1000) {
if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
netdev_dbg(padapter->pnetdev,
- FUNC_ADPT_FMT " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_FMT
+ " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
FUNC_ADPT_ARG(padapter),
no_gkey_bc_cnt,
no_gkey_mc_cnt);
@@ -550,7 +570,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
netdev_dbg(padapter->pnetdev,
- FUNC_ADPT_FMT " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_FMT
+ " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
FUNC_ADPT_ARG(padapter),
no_gkey_bc_cnt,
no_gkey_mc_cnt);
@@ -566,7 +587,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
iv = pframe + prxattrib->hdrlen;
payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
- length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
+ length = ((union recv_frame *)precvframe)->u.hdr.len -
+ prxattrib->hdrlen - prxattrib->iv_len;
GET_TKIP_PN(iv, dot11txpn);
@@ -757,10 +779,12 @@ static void construct_ctr_preload(u8 *ctr_preload,
if (frtype == WIFI_MGT_TYPE)
ctr_preload[1] |= BIT(4);
+ /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
for (i = 2; i < 8; i++)
- ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
+ ctr_preload[i] = mpdu[i + 8];
+ /* ctr_preload[8:13] = PN[5:0] */
for (i = 8; i < 14; i++)
- ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */
+ ctr_preload[i] = pn_vector[13 - i];
ctr_preload[14] = (unsigned char)(c / 256); /* Ctr */
ctr_preload[15] = (unsigned char)(c % 256);
}
@@ -952,11 +976,13 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */
- length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
+ length = pattrib->last_txcmdsz - pattrib->hdrlen -
+ pattrib->iv_len - pattrib->icv_len;
aes_cipher(prwskey, pattrib->hdrlen, pframe, length);
} else {
- length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
+ length = pxmitpriv->frag_len - pattrib->hdrlen -
+ pattrib->iv_len - pattrib->icv_len;
aes_cipher(prwskey, pattrib->hdrlen, pframe, length);
pframe += pxmitpriv->frag_len;
@@ -1205,7 +1231,8 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
if (jiffies_to_msecs(jiffies - start) > 1000) {
if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
netdev_dbg(padapter->pnetdev,
- FUNC_ADPT_FMT " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_FMT
+ " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
FUNC_ADPT_ARG(padapter),
no_gkey_bc_cnt,
no_gkey_mc_cnt);
@@ -1220,7 +1247,8 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
netdev_dbg(padapter->pnetdev,
- FUNC_ADPT_FMT " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_FMT
+ " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
FUNC_ADPT_ARG(padapter),
no_gkey_bc_cnt,
no_gkey_mc_cnt);
@@ -1238,7 +1266,8 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
prwskey = &stainfo->dot118021x_UncstKey.skey[0];
}
- length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
+ length = ((union recv_frame *)precvframe)->u.hdr.len -
+ prxattrib->hdrlen - prxattrib->iv_len;
res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length);
@@ -1269,9 +1298,14 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)
/* mapping to wlan header */
pwlanhdr = (struct ieee80211_hdr *)pframe;
/* save the frame body + MME */
- memcpy(BIP_AAD + BIP_AAD_SIZE, pframe + WLAN_HDR_A3_LEN, pattrib->pkt_len - WLAN_HDR_A3_LEN);
+ memcpy(BIP_AAD + BIP_AAD_SIZE,
+ pframe + WLAN_HDR_A3_LEN,
+ pattrib->pkt_len - WLAN_HDR_A3_LEN);
/* find MME IE pointer */
- p = rtw_get_ie(BIP_AAD + BIP_AAD_SIZE, WLAN_EID_MMIE, &len, pattrib->pkt_len - WLAN_HDR_A3_LEN);
+ p = rtw_get_ie(BIP_AAD + BIP_AAD_SIZE,
+ WLAN_EID_MMIE,
+ &len,
+ pattrib->pkt_len - WLAN_HDR_A3_LEN);
/* Baron */
if (p) {
u16 keyid = 0;
@@ -1300,8 +1334,10 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)
/* conscruct AAD, copy address 1 to address 3 */
memcpy(BIP_AAD + 2, &pwlanhdr->addrs, sizeof(pwlanhdr->addrs));
- if (omac1_aes_128(padapter->securitypriv.dot11wBIPKey[padapter->securitypriv.dot11wBIPKeyid].skey
- , BIP_AAD, ori_len, mic))
+ int bip_keyid = padapter->securitypriv.dot11wBIPKeyid;
+ u8 *bip_key = padapter->securitypriv.dot11wBIPKey[bip_keyid].skey;
+
+ if (omac1_aes_128(bip_key, BIP_AAD, ori_len, mic))
goto BIP_exit;
/* MIC field should be last 8 bytes of packet (packet without FCS) */
@@ -1430,7 +1466,8 @@ void rtw_sec_restore_wep_key(struct adapter *adapter)
struct security_priv *securitypriv = &adapter->securitypriv;
signed int keyid;
- if ((securitypriv->dot11_privacy_algrthm == _WEP40_) || (securitypriv->dot11_privacy_algrthm == _WEP104_)) {
+ if ((securitypriv->dot11_privacy_algrthm == _WEP40_) ||
+ (securitypriv->dot11_privacy_algrthm == _WEP104_)) {
for (keyid = 0; keyid < 4; keyid++) {
if (securitypriv->key_mask & BIT(keyid)) {
if (keyid == securitypriv->dot11PrivacyKeyIndex)
@@ -1448,7 +1485,8 @@ u8 rtw_handle_tkip_countermeasure(struct adapter *adapter, const char *caller)
u8 status = _SUCCESS;
if (securitypriv->btkip_countermeasure) {
- unsigned long passing_ms = jiffies_to_msecs(jiffies - securitypriv->btkip_countermeasure_time);
+ unsigned long elapsed = jiffies - securitypriv->btkip_countermeasure_time;
+ unsigned long passing_ms = jiffies_to_msecs(elapsed);
if (passing_ms > 60 * 1000) {
netdev_dbg(adapter->pnetdev,
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] staging: rtl8723bs: fix lines exceeding 100 columns in rtw_security.c
2026-09-15 7:29 [PATCH v2] staging: rtl8723bs: fix lines exceeding 100 columns in rtw_security.c Rareș-Mihai Vladu
@ 2026-09-15 7:58 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-09-15 7:58 UTC (permalink / raw)
To: Rareș-Mihai Vladu; +Cc: gregkh, linux-staging, linux-kernel, lkp
On Tue, Sep 15, 2026 at 07:29:23AM +0000, Rareș-Mihai Vladu wrote:
> Reformat long lines in rtw_security.c to fit within the 100-column
> limit by splitting function arguments, expressions, and moving
>
> Signed-off-by: Rareș-Mihai Vladu <vladurares@gmail.com>
> ---
What changed?
https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/
> @@ -112,9 +119,16 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
> keyindex = prxattrib->key_index;
> keylength = psecuritypriv->dot11DefKeylen[keyindex];
> memcpy(&wepkey[0], iv, 3);
> - /* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */
> - memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength);
> - length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
> + /*
> + * memcpy(&wepkey[3],
> + * &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0],
> + * keylength);
> + */
Don't worry about polishing dead code, just delete it. (In a separate
patch).
> + memcpy(&wepkey[3],
> + &psecuritypriv->dot11DefKey[keyindex].skey[0],
> + keylength);
> + length = ((union recv_frame *)precvframe)->u.hdr.len -
> + prxattrib->hdrlen - prxattrib->iv_len;
>
> payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
>
[ snip ]
> @@ -1300,8 +1334,10 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)
> /* conscruct AAD, copy address 1 to address 3 */
> memcpy(BIP_AAD + 2, &pwlanhdr->addrs, sizeof(pwlanhdr->addrs));
>
> - if (omac1_aes_128(padapter->securitypriv.dot11wBIPKey[padapter->securitypriv.dot11wBIPKeyid].skey
> - , BIP_AAD, ori_len, mic))
> + int bip_keyid = padapter->securitypriv.dot11wBIPKeyid;
> + u8 *bip_key = padapter->securitypriv.dot11wBIPKey[bip_keyid].skey;
Don't declare variables in the middle of code unless it's a __cleanup
variable.
> +
> + if (omac1_aes_128(bip_key, BIP_AAD, ori_len, mic))
> goto BIP_exit;
>
> /* MIC field should be last 8 bytes of packet (packet without FCS) */
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-15 7:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 7:29 [PATCH v2] staging: rtl8723bs: fix lines exceeding 100 columns in rtw_security.c Rareș-Mihai Vladu
2026-09-15 7:58 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®