* [PATCH 0/3] ASoC: Use kcalloc() instead of kzalloc()
@ 2025-08-20 12:34 Qianfeng Rong
2025-08-20 12:34 ` [PATCH 2/3] ASoC: fsl: " Qianfeng Rong
2025-08-20 22:17 ` [PATCH 0/3] ASoC: " Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Qianfeng Rong @ 2025-08-20 12:34 UTC (permalink / raw)
To: Nick Li, Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Kuninori Morimoto,
Andrew Davis, Chen Ni, Linus Walleij, Qianfeng Rong, Al Viro,
open list:FOURSEMI AUDIO AMPLIFIER DRIVER, open list,
open list:FREESCALE SOC SOUND DRIVERS,
open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
Replace devm_kzalloc() with devm_kcalloc() in sound/soc. As noted in the
kernel documentation [1], open-coded multiplication in allocator arguments
is discouraged because it can lead to integer overflow.
Using devm_kcalloc() provides built-in overflow protection, making the
memory allocation safer when calculating the allocation size compared
to explicit multiplication.
[1]: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
Qianfeng Rong (3):
ASoC: codecs: Use kcalloc() instead of kzalloc()
ASoC: fsl: Use kcalloc() instead of kzalloc()
ASoC: test-component: Use kcalloc() instead of kzalloc()
sound/soc/codecs/fs-amp-lib.c | 2 +-
sound/soc/codecs/pcm6240.c | 4 ++--
sound/soc/fsl/fsl_sai.c | 2 +-
sound/soc/fsl/imx-audmux.c | 2 +-
sound/soc/generic/test-component.c | 4 ++--
5 files changed, 7 insertions(+), 7 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/3] ASoC: fsl: Use kcalloc() instead of kzalloc()
2025-08-20 12:34 [PATCH 0/3] ASoC: Use kcalloc() instead of kzalloc() Qianfeng Rong
@ 2025-08-20 12:34 ` Qianfeng Rong
2025-08-20 22:17 ` [PATCH 0/3] ASoC: " Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Qianfeng Rong @ 2025-08-20 12:34 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
open list:FREESCALE SOC SOUND DRIVERS,
open list:FREESCALE SOC SOUND DRIVERS, open list,
open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
Cc: Qianfeng Rong
Use devm_kcalloc() in fsl_sai_read_dlcfg() and imx_audmux_probe() 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>
---
sound/soc/fsl/fsl_sai.c | 2 +-
sound/soc/fsl/imx-audmux.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index cac064a60349..757e7868e322 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -1345,7 +1345,7 @@ static int fsl_sai_read_dlcfg(struct fsl_sai *sai)
num_cfg = elems / 3;
/* Add one more for default value */
- cfg = devm_kzalloc(&pdev->dev, (num_cfg + 1) * sizeof(*cfg), GFP_KERNEL);
+ cfg = devm_kcalloc(&pdev->dev, num_cfg + 1, sizeof(*cfg), GFP_KERNEL);
if (!cfg)
return -ENOMEM;
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index cc2918ee2cf5..f8335a04595a 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -305,7 +305,7 @@ static int imx_audmux_probe(struct platform_device *pdev)
return -EINVAL;
}
- regcache = devm_kzalloc(&pdev->dev, sizeof(u32) * reg_max, GFP_KERNEL);
+ regcache = devm_kcalloc(&pdev->dev, reg_max, sizeof(u32), GFP_KERNEL);
if (!regcache)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 0/3] ASoC: Use kcalloc() instead of kzalloc()
2025-08-20 12:34 [PATCH 0/3] ASoC: Use kcalloc() instead of kzalloc() Qianfeng Rong
2025-08-20 12:34 ` [PATCH 2/3] ASoC: fsl: " Qianfeng Rong
@ 2025-08-20 22:17 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2025-08-20 22:17 UTC (permalink / raw)
To: Nick Li, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Kuninori Morimoto,
Andrew Davis, Chen Ni, Linus Walleij, Al Viro, linux-sound,
linux-kernel, linuxppc-dev, imx, linux-arm-kernel, Qianfeng Rong
On Wed, 20 Aug 2025 20:34:17 +0800, Qianfeng Rong wrote:
> Replace devm_kzalloc() with devm_kcalloc() in sound/soc. As noted in the
> kernel documentation [1], open-coded multiplication in allocator arguments
> is discouraged because it can lead to integer overflow.
>
> Using devm_kcalloc() provides built-in overflow protection, making the
> memory allocation safer when calculating the allocation size compared
> to explicit multiplication.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/3] ASoC: codecs: Use kcalloc() instead of kzalloc()
commit: 45441b933cdfb7a018674049f269d7a1bc1688df
[2/3] ASoC: fsl: Use kcalloc() instead of kzalloc()
commit: 3b6f4bd6cda2797b0d999a129376c112d41604f4
[3/3] ASoC: test-component: Use kcalloc() instead of kzalloc()
commit: 96bcb34df55f7fee99795127c796315950c94fed
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-20 22:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 12:34 [PATCH 0/3] ASoC: Use kcalloc() instead of kzalloc() Qianfeng Rong
2025-08-20 12:34 ` [PATCH 2/3] ASoC: fsl: " Qianfeng Rong
2025-08-20 22:17 ` [PATCH 0/3] ASoC: " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).