Skip to content

Commit 9a0352d

Browse files
qianfengrongpaulmckrcu
authored andcommitted
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>
1 parent 3e15ccc commit 9a0352d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/rcu/refscale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ static int main_func(void *arg)
10211021
set_user_nice(current, MAX_NICE);
10221022

10231023
VERBOSE_SCALEOUT("main_func task started");
1024-
result_avg = kzalloc(nruns * sizeof(*result_avg), GFP_KERNEL);
1024+
result_avg = kcalloc(nruns, sizeof(*result_avg), GFP_KERNEL);
10251025
buf = kzalloc(800 + 64, GFP_KERNEL);
10261026
if (!result_avg || !buf) {
10271027
SCALEOUT_ERRSTRING("out of memory");

0 commit comments

Comments
 (0)