]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: rtl8723bs: use guard clause for AES check
authorLin YuChen <starpt.official@gmail.com>
Thu, 19 Mar 2026 12:07:36 +0000 (20:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 31 Mar 2026 08:30:27 +0000 (10:30 +0200)
Refactor the AES encryption check by using a guard clause to
reduce the indentation level of the subsequent logic.

Signed-off-by: Lin YuChen <starpt.official@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/20260319120737.29692-2-starpt.official@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/core/rtw_security.c

index b98bc1aa9cbe586cb0dca733e5a23000feb6ec79..54640fa409b3de6b4df939ad2fdddcbf163e53f5 100644 (file)
@@ -1209,68 +1209,68 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
 
        pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data;
        /* 4 start to encrypt each fragment */
-       if (prxattrib->encrypt == _AES_) {
-               stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
-               if (stainfo) {
-                       if (is_multicast_ether_addr(prxattrib->ra)) {
-                               static unsigned long start;
-                               static u32 no_gkey_bc_cnt;
-                               static u32 no_gkey_mc_cnt;
-
-                               if (!psecuritypriv->binstallGrpkey) {
-                                       res = _FAIL;
-
-                                       if (start == 0)
-                                               start = jiffies;
+       if (prxattrib->encrypt != _AES_)
+               return _SUCCESS;
+       stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
+       if (stainfo) {
+               if (is_multicast_ether_addr(prxattrib->ra)) {
+                       static unsigned long start;
+                       static u32 no_gkey_bc_cnt;
+                       static u32 no_gkey_mc_cnt;
+
+                       if (!psecuritypriv->binstallGrpkey) {
+                               res = _FAIL;
 
-                                       if (is_broadcast_mac_addr(prxattrib->ra))
-                                               no_gkey_bc_cnt++;
-                                       else
-                                               no_gkey_mc_cnt++;
+                               if (start == 0)
+                                       start = jiffies;
 
-                                       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_ARG(padapter),
-                                                                  no_gkey_bc_cnt,
-                                                                  no_gkey_mc_cnt);
-                                               }
-                                               start = jiffies;
-                                               no_gkey_bc_cnt = 0;
-                                               no_gkey_mc_cnt = 0;
+                               if (is_broadcast_mac_addr(prxattrib->ra))
+                                       no_gkey_bc_cnt++;
+                               else
+                                       no_gkey_mc_cnt++;
+
+                               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_ARG(padapter),
+                                                          no_gkey_bc_cnt,
+                                                          no_gkey_mc_cnt);
                                        }
-
-                                       goto exit;
+                                       start = jiffies;
+                                       no_gkey_bc_cnt = 0;
+                                       no_gkey_mc_cnt = 0;
                                }
 
-                               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_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];
+                               goto exit;
                        }
 
-                       length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
-
-                       res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length);
+                       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_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 {
-                       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);
+
+       } else {
+               res = _FAIL;
        }
 exit:
        return res;