summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQianfeng Rong <rongqianfeng@vivo.com>2025-08-21 21:41:17 +0800
committerPaul E. McKenney <paulmck@kernel.org>2025-08-22 06:26:22 -0700
commit9a0352dd45225597cb8d4a4d79cf5b53f3609ae3 (patch)
tree3c38e0c0b801e84468b1d4c6bec7fb7fab49505d
parent3e15cccf3ea272ae40942e8a5a741bb69a56f654 (diff)
refscale: Use kcalloc() instead of kzalloc()
Use kcalloc() in main_func() to gain built-in overflow protection, making memory allocation safer when calculating allocation size compared to explicit multiplication. Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
-rw-r--r--kernel/rcu/refscale.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index df646e0694a8..5840fac06feb 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -1021,7 +1021,7 @@ static int main_func(void *arg)
set_user_nice(current, MAX_NICE);
VERBOSE_SCALEOUT("main_func task started");
- result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL);
+ result_avg = kcalloc(nruns, sizeof(*result_avg), GFP_KERNEL);
buf = kzalloc(800 + 64, GFP_KERNEL);
if (!result_avg || !buf) {
SCALEOUT_ERRSTRING("out of memory");