Re: [PATCH] staging: rtl8723bs: Use kmemdup() to replace kzalloc() followed by memcpy()

From: Ethan Tidmore

Date: Sun Mar 15 2026 - 17:36:42 EST


On Sun Mar 15, 2026 at 2:47 PM CDT, Oarora Etimis wrote:
> The kzalloc() function allocates memory and zero-initializes it.
> However, in rtw_cfg80211_set_wpa_ie(), the allocated buffer is
> immediately overwritten by memcpy(). This makes the zero-initialization
> completely unnecessary, wasting CPU cycles.
>
> Use kmemdup() to simplify the code, eliminate the redundant memcpy(),
> and remove the unnecessary zeroing overhead.
>
> Signed-off-by: Oarora Etimis <OaroraEtimis@xxxxxxxxx>
> ---

This doesn't apply to staging-next.

>
> - memcpy(buf, pie, ielen);
> -
> if (ielen < RSN_HEADER_LEN) {
> - ret = -1;
> + ret = -1;
> goto exit;
> }
>

Also, this is a stray change. Keep one logical change per patch.

Thanks,

ET