[PATCH 0/3] ASoC: Use kcalloc() instead of kzalloc()

Qianfeng Rong posted 3 patches 1 month, 2 weeks ago
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(-)
[PATCH 0/3] ASoC: Use kcalloc() instead of kzalloc()
Posted by Qianfeng Rong 1 month, 2 weeks ago
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
Re: [PATCH 0/3] ASoC: Use kcalloc() instead of kzalloc()
Posted by Mark Brown 1 month, 2 weeks ago
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