[PATCH v6] staging: rtl8723bs: use kmemdup() in rtw_cfg80211_set_wpa_ie

Alexandru Hossu posted 1 patch 1 month ago
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH v6] staging: rtl8723bs: use kmemdup() in rtw_cfg80211_set_wpa_ie
Posted by Alexandru Hossu 1 month ago
Replace open-coded kzalloc()+memcpy() with kmemdup() to simplify the code.

Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
---
v6:
  - Rebase onto staging-next.
  - Limit changes to ioctl_cfg80211.c since sdio_ops.c is already fixed there.
  - Place version notes below the --- line (canonical patch format).

 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 47cba32375d9..453ba1db773f 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.43.0
Re: [PATCH v6] staging: rtl8723bs: use kmemdup() in rtw_cfg80211_set_wpa_ie
Posted by Dan Carpenter 1 month ago
On Thu, Mar 05, 2026 at 11:23:18AM +0100, Alexandru Hossu wrote:
> Replace open-coded kzalloc()+memcpy() with kmemdup() to simplify the code.
> 
> Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
> ---
> v6:
>   - Rebase onto staging-next.
>   - Limit changes to ioctl_cfg80211.c since sdio_ops.c is already fixed there.
>   - Place version notes below the --- line (canonical patch format).
> 

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

regards,
dan carpenter