Unverified Commit 63d93f4d authored by Ethan Carter Edwards's avatar Ethan Carter Edwards Committed by Mark Brown
Browse files

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: default avatarEthan Carter Edwards <ethan@ethancedwards.com>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patch.msgid.link/20250222-q6apm-kcalloc-v1-1-6f09dae6c31c@ethancedwards.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a5a3de89
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;