staging: rtl8723bs: clean up memcpy() in rtw_check_bcn_info
PATCH v2 1/1 staging: rtl8723bs: clean up memcpy() in rtw_check_bcn_info
From: Luka Gejak <[email protected]>
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.
---
As Dan pointed out kernel handles 0-length memcpy() safely as a no-op therefore it doesn't cause kernel oops or panics so in v2 changed commit message to move from bugfix to cleanup and removed fixes tag.
drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +1 -1
@@ -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) ||
Signature · 1 line
2.53.0
Quoted 9 lines · On Wed, Apr 15, 2026 at 10:56:38AM +0200, [email protected] wrote:
From: Luka Gejak <[email protected]>
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.
Quoted 5 lines
Signed-off-by Luka Gejak <[email protected]>---
As Dan pointed out kernel handles 0-lengthmemcpy()safely as a no-op therefore it doesn't cause kernel oops or panics so in v2 changed commit message to move from bugfix to cleanup and removed fixes tag.
Thanks.
regards,
dan carpenter