From: Ethan Carter Edwards Date: Sat, 22 Feb 2025 19:55:20 +0000 (-0500) Subject: ASoC: q6dsp: q6apm: replace kzalloc() with kcalloc() in q6apm_map_memory_regions() X-Git-Tag: v6.15-rc1~173^2~4^2~90 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63d93f4d0f38fbb95a55729fbd2cc4920743931c;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Dmitry Baryshkov Link: https://patch.msgid.link/20250222-q6apm-kcalloc-v1-1-6f09dae6c31c@ethancedwards.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 2a2a5bd98110b..11e252a70f697 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -230,7 +230,7 @@ int q6apm_map_memory_regions(struct q6apm_graph *graph, unsigned int dir, phys_a return 0; } - buf = kzalloc(((sizeof(struct audio_buffer)) * periods), GFP_KERNEL); + buf = kcalloc(periods, sizeof(struct audio_buffer), GFP_KERNEL); if (!buf) { mutex_unlock(&graph->lock); return -ENOMEM;