Re: [PATCH v2?] ASoC: q6dsp: q6apm: replace kzalloc() with kcalloc() in q6apm_map_memory_regions()

From: Markus Elfring
Date: Sun Feb 23 2025 - 04:50:48 EST



> We are trying to get rid of all multiplications from allocation
> functions to prevent integer overflows[1]. …

Is an imperative wording more desirable for such a change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14-rc3#n94



> ---
> sound/soc/qcom/qdsp6/q6apm.c | 2 +-


How do you think about to improve your version management?
https://lore.kernel.org/all/?q=%22This+looks+like+a+new+version+of+a+previously+submitted+patch%22
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14-rc3#n780



> +++ 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);


See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.14-rc3#n941


How do you think about to increase the application of scope-based resource management?

Regards,
Markus