[PATCH] staging: rtl8723bs: replace kmalloc + memcpy with kmemdup in ioctl_cfg80211.c
From: Tomasz Unger
Date: Sat Mar 14 2026 - 05:12:02 EST
Replace kmalloc() followed by memcpy() with kmemdup() which combines
both operations into a single call, making the code cleaner and more
readable. The zeroing done by kzalloc() is unnecessary here as the
entire buffer is immediately overwritten by memcpy().
Signed-off-by: Tomasz Unger <tomasz.unger@xxxxxxxx>
---
Verified with checkpatch.pl - no errors or warnings.
Compiled the rtl8723bs module successfully.
Tested by loading the module in a QEMU environment - module loads
successfully with no errors.
---
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 7cb0c6f22bf3..2125606f7775 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1430,14 +1430,12 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
goto exit;
}
- buf = kzalloc(ielen, GFP_KERNEL);
+ buf = kmemdup(pie, ielen, GFP_KERNEL);
if (!buf) {
ret = -ENOMEM;
goto exit;
}
- memcpy(buf, pie, ielen);
-
if (ielen < RSN_HEADER_LEN) {
ret = -1;
goto exit;
---
base-commit: 2f10e53847d208e97f23ceef3678ce8c88d2ae0e
change-id: 20260314-rtl8723bs-kmemdup-95dfbc18ee66
Best regards,
--
Tomasz Unger <tomasz.unger@xxxxxxxx>