* [PATCH] staging: rtl8723bs: replace kmalloc + memcpy with kmemdup in ioctl_cfg80211.c [not found] <20260314-rtl8723bs-kmemdup-v1-1-8280a436f20c.ref@yahoo.pl> @ 2026-03-14 9:11 ` Tomasz Unger 2026-03-14 10:00 ` Greg Kroah-Hartman 2026-03-14 21:09 ` Ethan Tidmore 0 siblings, 2 replies; 3+ messages in thread From: Tomasz Unger @ 2026-03-14 9:11 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, Tomasz Unger 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> ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: rtl8723bs: replace kmalloc + memcpy with kmemdup in ioctl_cfg80211.c 2026-03-14 9:11 ` [PATCH] staging: rtl8723bs: replace kmalloc + memcpy with kmemdup in ioctl_cfg80211.c Tomasz Unger @ 2026-03-14 10:00 ` Greg Kroah-Hartman 2026-03-14 21:09 ` Ethan Tidmore 1 sibling, 0 replies; 3+ messages in thread From: Greg Kroah-Hartman @ 2026-03-14 10:00 UTC (permalink / raw) To: Tomasz Unger; +Cc: linux-staging, linux-kernel 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: rtl8723bs: replace kmalloc + memcpy with kmemdup in ioctl_cfg80211.c 2026-03-14 9:11 ` [PATCH] staging: rtl8723bs: replace kmalloc + memcpy with kmemdup in ioctl_cfg80211.c Tomasz Unger 2026-03-14 10:00 ` Greg Kroah-Hartman @ 2026-03-14 21:09 ` Ethan Tidmore 1 sibling, 0 replies; 3+ messages in thread From: Ethan Tidmore @ 2026-03-14 21:09 UTC (permalink / raw) To: Tomasz Unger, Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-14 21:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260314-rtl8723bs-kmemdup-v1-1-8280a436f20c.ref@yahoo.pl>
2026-03-14 9:11 ` [PATCH] staging: rtl8723bs: replace kmalloc + memcpy with kmemdup in ioctl_cfg80211.c Tomasz Unger
2026-03-14 10:00 ` Greg Kroah-Hartman
2026-03-14 21:09 ` Ethan Tidmore
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox