drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
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@yahoo.pl>
---
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@yahoo.pl>
On Sat Mar 14, 2026 at 4:11 AM CDT, Tomasz Unger wrote: > 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@yahoo.pl> > --- This doesn't apply to staging-next. Thanks, ET
On Sat, Mar 14, 2026 at 10:11:39AM +0100, Tomasz Unger wrote: > 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@yahoo.pl> > --- > 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. Loading a module doesn't do anything (you can do that on a raspberrypi), you have to have the hardware to bind to the driver and actually call the ioctl to verify it works. So while loading is nice, you didn't actually exercise your change at all :( Not to say this change is not correct, just be a bit more careful as to how you attempt to test this please. thanks, greg k-h
© 2016 - 2026 Red Hat, Inc.