public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Alexandru Hossu <hossu.alexandru@gmail.com>
Cc: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] staging: rtl8723bs: replace alloc+memcpy with kmemdup
Date: Thu, 5 Mar 2026 08:51:30 +0300	[thread overview]
Message-ID: <aakZ4s2sPtROzmpr@stanley.mountain> (raw)
In-Reply-To: <20260305010917.40320-1-hossu.alexandru@gmail.com>

On Thu, Mar 05, 2026 at 02:09:17AM +0100, Alexandru Hossu wrote:
> Replace open-coded alloc+memcpy patterns with kmemdup().
> 
> This simplifies the code and avoids manual size/copy handling.
> 
> Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
> ---
> v5:
>   - Move version history below the --- line (per submitting-patches).
> 
> v4:
>   - Drop unrelated DT binding changes from earlier attempts.
>   - Include both rtl8723bs changes in one staging-only patch.
>   - Wrap long line reported by checkpatch.
> 
>  drivers/staging/rtl8723bs/hal/sdio_ops.c          | 3 +--
>  drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
> index c9cb20c61..6e03d3d8a 100644
> --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
> +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
> @@ -583,11 +583,10 @@ s32 sdio_local_write(
>  	)
>  		return sd_cmd52_write(intfhdl, addr, cnt, buf);
>  
> -	tmpbuf = kmalloc(cnt, GFP_ATOMIC);
> +	tmpbuf = kmemdup(buf, cnt, GFP_ATOMIC);
>  	if (!tmpbuf)
>  		return -ENOMEM;
>  
> -	memcpy(tmpbuf, buf, cnt);
>  

Delete the extra blank line.  Also this doesn't apply to linux-next
but I haven't investigated further.

>  	err = sd_write(intfhdl, addr, cnt, tmpbuf);
>  
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> index 7cb0c6f22..0ae7b6389 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> @@ -1430,13 +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);
>  

Extra blank line.

regards,
dan carpenter

>  	if (ielen < RSN_HEADER_LEN) {
>  		ret  = -1;
> -- 
> 2.43.0
> 

      reply	other threads:[~2026-03-05  5:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04 13:07 [PATCH v2] staging: rtl8723bs: replace kzalloc/kmalloc+memcpy with kmemdup Alexandru Hossu
2026-03-04 13:24 ` Greg KH
2026-03-04 13:51 ` [PATCH v3] " Alexandru Hossu
2026-03-04 13:59 ` [PATCH v4] staging: rtl8723bs: replace alloc+memcpy " Alexandru Hossu
2026-03-04 14:48   ` Greg KH
2026-03-05 10:23   ` [PATCH v6] staging: rtl8723bs: use kmemdup() in rtw_cfg80211_set_wpa_ie Alexandru Hossu
2026-03-05 10:39     ` Dan Carpenter
2026-03-05  1:09 ` [PATCH v5] staging: rtl8723bs: replace alloc+memcpy with kmemdup Alexandru Hossu
2026-03-05  5:51   ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aakZ4s2sPtROzmpr@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hossu.alexandru@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox