public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2] staging: rtl8723bs: replace kzalloc/memcpy with kmemdup
@ 2026-03-09 14:21 Lin YuChen
  2026-03-09 16:51 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Lin YuChen @ 2026-03-09 14:21 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, starpt.official

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>
---
v2:
 - Use real name in Signed-off-by line as requested by Ethan Tidmore.
 - Fix a minor whitespace issue in the error return path.
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 7cb0c6f22bf3..3db6417a7de1 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;
+		ret = -ENOMEM;
 		goto exit;
 	}
 
-	memcpy(buf, pie, ielen);
-
 	if (ielen < RSN_HEADER_LEN) {
 		ret  = -1;
 		goto exit;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] staging: rtl8723bs: replace kzalloc/memcpy with kmemdup
  2026-03-09 14:21 [PATCH v2] staging: rtl8723bs: replace kzalloc/memcpy with kmemdup Lin YuChen
@ 2026-03-09 16:51 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2026-03-09 16:51 UTC (permalink / raw)
  To: Lin YuChen; +Cc: linux-staging, linux-kernel

On Mon, Mar 09, 2026 at 10:21:50PM +0800, 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>
> ---
> v2:
>  - Use real name in Signed-off-by line as requested by Ethan Tidmore.
>  - Fix a minor whitespace issue in the error return path.
>  drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> index 7cb0c6f22bf3..3db6417a7de1 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;
> +		ret = -ENOMEM;

You also changed the spacing here, while normally ok, it's not good for
a first patch.  Please only do one logical-thing-per-patch.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-09 16:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 14:21 [PATCH v2] staging: rtl8723bs: replace kzalloc/memcpy with kmemdup Lin YuChen
2026-03-09 16:51 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox