Commit 9a0352dd authored by Qianfeng Rong's avatar Qianfeng Rong Committed by Paul E. McKenney
Browse files

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: default avatarQianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent 3e15cccf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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");