staging: r8188eu: return immediately if we're not meant to encrypt
authorMartin Kaiser <martin@kaiser.cx>
Fri, 30 Dec 2022 18:06:30 +0000 (19:06 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Jan 2023 18:31:21 +0000 (19:31 +0100)
In function xmitframe_swencrypt, we can return immediately if our packet
needs no encryption. This is simpler than wrapping all the code into a
large if statement.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Link: https://lore.kernel.org/r/20221230180646.91008-5-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_xmit.c

index 55c6587..5584202 100644 (file)
@@ -765,21 +765,22 @@ static void xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxm
 {
        struct  pkt_attrib       *pattrib = &pxmitframe->attrib;
 
-       if (pattrib->bswenc) {
-               switch (pattrib->encrypt) {
-               case _WEP40_:
-               case _WEP104_:
-                       rtw_wep_encrypt(padapter, pxmitframe);
-                       break;
-               case _TKIP_:
-                       rtw_tkip_encrypt(padapter, pxmitframe);
-                       break;
-               case _AES_:
-                       rtw_aes_encrypt(padapter, pxmitframe);
-                       break;
-               default:
-                       break;
-               }
+       if (!pattrib->bswenc)
+               return;
+
+       switch (pattrib->encrypt) {
+       case _WEP40_:
+       case _WEP104_:
+               rtw_wep_encrypt(padapter, pxmitframe);
+               break;
+       case _TKIP_:
+               rtw_tkip_encrypt(padapter, pxmitframe);
+               break;
+       case _AES_:
+               rtw_aes_encrypt(padapter, pxmitframe);
+               break;
+       default:
+               break;
        }
 }