Re: [PATCH] ASoC: q6dsp: q6apm: change kzalloc to kcalloc
Markus Elfring <[email protected]> Sun, 9 Feb 2025 11:15:59 +0100
| Newsgroups | com.openwall.lists.kernel-hardening,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-hardening,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound |
|---|---|
| Message-ID | <[email protected]> |
> 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/Do= cumentation/process/submitting-patches.rst?h=3Dv6.13#n94 =E2=80=A6 > +++ b/sound/soc/qcom/qdsp6/q6apm.c > @@ -230,7 +230,7 @@ int q6apm_map_memory_regions(struct q6apm_graph *gra= ph, unsigned int dir, phys_a > return 0; > } > > - buf =3D kzalloc(((sizeof(struct audio_buffer)) * periods), GFP_KERNEL)= ; > + buf =3D kcalloc(periods, sizeof(struct audio_buffer), GFP_KERNEL); =E2=80=A6 See also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Do= cumentation/process/coding-style.rst?h=3Dv6.13#n941 How do you think about to increase the application of scope-based resource= management? Regards, Markus