From: Su Hui <suhui@nfschina.com>
To: dave@stgolabs.net, paulmck@kernel.org, josh@joshtriplett.org,
frederic@kernel.org, neeraj.upadhyay@kernel.org,
joel@joelfernandes.org, boqun.feng@gmail.com, urezki@gmail.com,
rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
jiangshanlai@gmail.com, qiang.zhang1211@gmail.com
Cc: Su Hui <suhui@nfschina.com>,
linux-kernel@vger.kernel.org, rcu@vger.kernel.org,
kernel-janitors@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: [PATCH] rcuscale: using kmalloc_array() to relpace kmalloc()
Date: Mon, 21 Apr 2025 14:15:09 +0800 [thread overview]
Message-ID: <20250421061508.718752-1-suhui@nfschina.com> (raw)
It's safer to using kmalloc_array() because it can prevent overflow
problem.
Signed-off-by: Su Hui <suhui@nfschina.com>
---
kernel/rcu/rcuscale.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
index 0f3059b1b80d..cbe2195f08d6 100644
--- a/kernel/rcu/rcuscale.c
+++ b/kernel/rcu/rcuscale.c
@@ -762,7 +762,7 @@ kfree_scale_thread(void *arg)
}
for (i = 0; i < kfree_alloc_num; i++) {
- alloc_ptr = kmalloc(kfree_mult * sizeof(struct kfree_obj), GFP_KERNEL);
+ alloc_ptr = kmalloc_array(kfree_mult, sizeof(struct kfree_obj), GFP_KERNEL);
if (!alloc_ptr)
return -ENOMEM;
--
2.30.2
next reply other threads:[~2025-04-21 6:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 6:15 Su Hui [this message]
2025-04-21 13:49 ` Paul E. McKenney
2025-04-22 1:37 ` Su Hui
2025-04-22 1:51 ` [PATCH v2] rcuscale: using kcalloc() " Su Hui
2025-04-22 17:58 ` Paul E. McKenney
2025-04-22 22:55 ` Joel Fernandes
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=20250421061508.718752-1-suhui@nfschina.com \
--to=suhui@nfschina.com \
--cc=boqun.feng@gmail.com \
--cc=dave@stgolabs.net \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang1211@gmail.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.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®