staging: rtl8723bs: use guard clause for stainfo check

Continue the refactor of rtw_aes_decrypt() by introducing a guard
clause for the stainfo check. This allows the subsequent multicast
and unicast decryption logic to be moved one indentation level to
the left, further improving code readability.

Signed-off-by: Lin YuChen <starpt.official@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/20260319120737.29692-3-starpt.official@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Lin YuChen 2026-03-19 20:07:37 +08:00 committed by Greg Kroah-Hartman
parent d359ab14db
commit e23ad15700

View File

@ -1212,66 +1212,64 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
if (prxattrib->encrypt != _AES_) if (prxattrib->encrypt != _AES_)
return _SUCCESS; return _SUCCESS;
stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
if (stainfo) { if (stainfo)
if (is_multicast_ether_addr(prxattrib->ra)) { return _FAIL;
static unsigned long start; if (is_multicast_ether_addr(prxattrib->ra)) {
static u32 no_gkey_bc_cnt; static unsigned long start;
static u32 no_gkey_mc_cnt; static u32 no_gkey_bc_cnt;
static u32 no_gkey_mc_cnt;
if (!psecuritypriv->binstallGrpkey) { if (!psecuritypriv->binstallGrpkey) {
res = _FAIL; res = _FAIL;
if (start == 0) if (start == 0)
start = jiffies; start = jiffies;
if (is_broadcast_mac_addr(prxattrib->ra)) if (is_broadcast_mac_addr(prxattrib->ra))
no_gkey_bc_cnt++; no_gkey_bc_cnt++;
else else
no_gkey_mc_cnt++; no_gkey_mc_cnt++;
if (jiffies_to_msecs(jiffies - start) > 1000) { if (jiffies_to_msecs(jiffies - start) > 1000) {
if (no_gkey_bc_cnt || no_gkey_mc_cnt) { if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
netdev_dbg(padapter->pnetdev, 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), FUNC_ADPT_ARG(padapter),
no_gkey_bc_cnt, no_gkey_bc_cnt,
no_gkey_mc_cnt); no_gkey_mc_cnt);
}
start = jiffies;
no_gkey_bc_cnt = 0;
no_gkey_mc_cnt = 0;
} }
start = jiffies;
goto exit; no_gkey_bc_cnt = 0;
no_gkey_mc_cnt = 0;
} }
if (no_gkey_bc_cnt || no_gkey_mc_cnt) { goto exit;
netdev_dbg(padapter->pnetdev,
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);
}
start = 0;
no_gkey_bc_cnt = 0;
no_gkey_mc_cnt = 0;
prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
if (psecuritypriv->dot118021XGrpKeyid != prxattrib->key_index) {
res = _FAIL;
goto exit;
}
} else {
prwskey = &stainfo->dot118021x_UncstKey.skey[0];
} }
length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len; if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
netdev_dbg(padapter->pnetdev,
res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); 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);
}
start = 0;
no_gkey_bc_cnt = 0;
no_gkey_mc_cnt = 0;
prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
if (psecuritypriv->dot118021XGrpKeyid != prxattrib->key_index) {
res = _FAIL;
goto exit;
}
} else { } else {
res = _FAIL; prwskey = &stainfo->dot118021x_UncstKey.skey[0];
} }
length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length);
exit: exit:
return res; return res;
} }