]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
staging: rtl8723bs: clean up memcpy() in rtw_check_bcn_info
authorLuka Gejak <luka.gejak@linux.dev>
Wed, 15 Apr 2026 08:56:38 +0000 (10:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Apr 2026 11:01:55 +0000 (05:01 -0600)
Move the ssid memcpy() inside the ie null-check to avoid calling it
with a NULL-derived pointer (p + 2) when the ie is missing.

While the kernel handles 0-length memcpy() safely as a no-op, keeping
the call outside the check is confusing and poor practice. This
change improves code readability.

Signed-off-by: Luka Gejak <luka.gejak@linux.dev>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Link: https://patch.msgid.link/20260415085638.6427-1-luka.gejak@linux.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/core/rtw_wlan_util.c

index c04419c9c3fc380a061ee9f00a72f8b770dc837c..3762ae6c4c65d60b07b24c0a310c4bbe56c92f1f 100644 (file)
@@ -1204,8 +1204,8 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
                ssid_len = *(p + 1);
                if (ssid_len > NDIS_802_11_LENGTH_SSID)
                        ssid_len = 0;
+               memcpy(bssid->ssid.ssid, (p + 2), ssid_len);
        }
-       memcpy(bssid->ssid.ssid, (p + 2), ssid_len);
        bssid->ssid.ssid_length = ssid_len;
 
        if (memcmp(bssid->ssid.ssid, cur_network->network.ssid.ssid, 32) ||