Re: [PATCH] ASoC: q6dsp: q6apm: change kzalloc to kcalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



> We are replacing any instances of kzalloc(size * count, ...) with
> kcalloc(count, size, ...) due to risk of overflow [1].

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.13#n94


…
> +++ 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.13#n941


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

Regards,
Markus





[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux