rcuscale: using kcalloc() to relpace kmalloc()
authorSu Hui <suhui@nfschina.com>
Tue, 22 Apr 2025 01:51:45 +0000 (09:51 +0800)
committerJoel Fernandes <joelagnelf@nvidia.com>
Fri, 16 May 2025 13:00:54 +0000 (09:00 -0400)
It's safer to using kcalloc() because it can prevent overflow
problem.

Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
kernel/rcu/rcuscale.c

index 0f3059b1b80d03ddb8884fa4352e9497f476eecf..b521d04559927a21acc2649d8e8dbbf848dd8a2f 100644 (file)
@@ -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 = kcalloc(kfree_mult, sizeof(struct kfree_obj), GFP_KERNEL);
                        if (!alloc_ptr)
                                return -ENOMEM;