From: Alexandru Hossu <hossu.alexandru@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH] staging: rtl8723bs: replace kzalloc/kmalloc+memcpy with kmemdup
Date: Wed, 4 Mar 2026 12:26:38 +0100 [thread overview]
Message-ID: <c6e77299-e978-40f1-a574-f2f1eec2eb78@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 194 bytes --]
Replace kzalloc/kmalloc followed by memcpy with kmemdup to simplify
code and avoid unnecessary zero-initialization before overwriting.
Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
[-- Attachment #2: 0001-staging-rtl8723bs-replace-kzalloc-kmalloc-memcpy-wit.patch --]
[-- Type: text/plain, Size: 1628 bytes --]
From 3ed44dff9cee65557deb3221402a9f8f9cb9957f Mon Sep 17 00:00:00 2001
From: Alexandru Hossu <hossu.alexandru@gmail.com>
Date: Wed, 4 Mar 2026 12:24:33 +0100
Subject: [PATCH] staging: rtl8723bs: replace kzalloc/kmalloc+memcpy with
kmemdup
Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
---
drivers/staging/rtl8723bs/hal/sdio_ops.c | 4 +---
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index c9cb20c61..514c857a9 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -583,12 +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);
-
err = sd_write(intfhdl, addr, cnt, tmpbuf);
kfree(tmpbuf);
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 7cb0c6f22..2125606f7 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
next reply other threads:[~2026-03-04 11:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 11:26 Alexandru Hossu [this message]
2026-03-04 14:13 ` [PATCH] staging: rtl8723bs: replace kzalloc/kmalloc+memcpy with kmemdup Dan Carpenter
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=c6e77299-e978-40f1-a574-f2f1eec2eb78@gmail.com \
--to=hossu.alexandru@gmail.com \
--cc=gregkh@linuxfoundation.org \
--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