Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: codecs: Use kcalloc() instead of kzalloc()

Use devm_kcalloc() in fs_parse_scene_tables() and pcmdev_gain_ctrl_add()
to gain built-in overflow protection, making memory allocation safer when
calculating allocation size compared to explicit multiplication.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Link: https://patch.msgid.link/20250820123423.470486-2-rongqianfeng@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Qianfeng Rong and committed by
Mark Brown
45441b93 132e098e

+3 -3
+1 -1
sound/soc/codecs/fs-amp-lib.c
··· 111 111 if (count <= 0) 112 112 return -EFAULT; 113 113 114 - scene = devm_kzalloc(amp_lib->dev, count * sizeof(*scene), GFP_KERNEL); 114 + scene = devm_kcalloc(amp_lib->dev, count, sizeof(*scene), GFP_KERNEL); 115 115 if (!scene) 116 116 return -ENOMEM; 117 117
+2 -2
sound/soc/codecs/pcm6240.c
··· 1353 1353 return 0; 1354 1354 } 1355 1355 1356 - pcmdev_controls = devm_kzalloc(pcm_dev->dev, 1357 - nr_chn * sizeof(struct snd_kcontrol_new), GFP_KERNEL); 1356 + pcmdev_controls = devm_kcalloc(pcm_dev->dev, nr_chn, 1357 + sizeof(struct snd_kcontrol_new), GFP_KERNEL); 1358 1358 if (!pcmdev_controls) 1359 1359 return -ENOMEM; 1360 1360