Replace the open-coded kzalloc and memcpy combination with kmemdup()
to make the code more concise and idiomatic.
Signed-off-by: Lin YuChen <starpt.official@gmail.com>
---
v3:
- Revert whitespace change to keep the patch atomic as requested by Greg.
v2:
- Use real name in Signed-off-by line as requested by Ethan Tidmore.
- Fix a minor whitespace issue in the error return path.
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;
--
2.34.1
On Tue Mar 10, 2026 at 2:22 PM CDT, Lin YuChen wrote: > Replace the open-coded kzalloc and memcpy combination with kmemdup() > to make the code more concise and idiomatic. > > Signed-off-by: Lin YuChen <starpt.official@gmail.com> > --- This same change has recently been merged [1]. Thanks, ET [1] https://patch.msgid.link/20260305102318.43034-1-hossu.alexandru@gmail.com
© 2016 - 2026 Red Hat, Inc.