rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rcuscale: using kmalloc_array() to relpace kmalloc()
@ 2025-04-21  6:15 Su Hui
  2025-04-21 13:49 ` Paul E. McKenney
  2025-04-22  1:51 ` [PATCH v2] rcuscale: using kcalloc() " Su Hui
  0 siblings, 2 replies; 6+ messages in thread
From: Su Hui @ 2025-04-21  6:15 UTC (permalink / raw)
  To: dave, paulmck, josh, frederic, neeraj.upadhyay, joel, boqun.feng,
	urezki, rostedt, mathieu.desnoyers, jiangshanlai, qiang.zhang1211
  Cc: Su Hui, linux-kernel, rcu, kernel-janitors, linux-hardening

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-04-22 22:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21  6:15 [PATCH] rcuscale: using kmalloc_array() to relpace kmalloc() Su Hui
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).