Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: q6dsp: q6apm: replace kzalloc() with kcalloc() in q6apm_map_memory_regions()

We are trying to get rid of all multiplications from allocation
functions to prevent integer overflows[1]. Here the multiplication is
obviously safe, but using kcalloc() is more appropriate and improves
readability. This patch has no effect on runtime behavior.

Link: https://github.com/KSPP/linux/issues/162 [1]
Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments

Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patch.msgid.link/20250222-q6apm-kcalloc-v1-1-6f09dae6c31c@ethancedwards.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Ethan Carter Edwards and committed by
Mark Brown
63d93f4d a5a3de89

+1 -1
+1 -1
sound/soc/qcom/qdsp6/q6apm.c
··· 230 230 return 0; 231 231 } 232 232 233 - buf = kzalloc(((sizeof(struct audio_buffer)) * periods), GFP_KERNEL); 233 + buf = kcalloc(periods, sizeof(struct audio_buffer), GFP_KERNEL); 234 234 if (!buf) { 235 235 mutex_unlock(&graph->lock); 236 236 return -ENOMEM;