From: Oarora Etimis <oaroraetimis@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Minu Jin <s9430939@naver.com>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Oarora Etimis <OaroraEtimis@gmail.com>
Subject: [PATCH] staging: rtl8723bs: Use kmemdup() to replace kzalloc() followed by memcpy()
Date: Mon, 16 Mar 2026 03:47:38 +0800 [thread overview]
Message-ID: <20260315194738.154324-1-OaroraEtimis@gmail.com> (raw)
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@gmail.com>
---
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 7cb0c6f22bf3..2f7fa5841578 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1430,16 +1430,14 @@ 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;
+ ret = -1;
goto exit;
}
--
2.47.3
next reply other threads:[~2026-03-15 19:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-15 19:47 Oarora Etimis [this message]
2026-03-15 21:36 ` Ethan Tidmore
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=20260315194738.154324-1-OaroraEtimis@gmail.com \
--to=oaroraetimis@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=s9430939@naver.com \
/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
all inboxes | Powered by JetHome®