ASoC: rockchip: rk3399_gru_sound: Allocate dai_link with ARRAY_SIZE()
Subsystems (3)
PATCH 1/1 ASoC: rockchip: rk3399_gru_sound: Allocate dai_link with ARRAY_SIZE()
From: Kees Cook <[email protected]>
In preparation for making the devm_kmalloc family of allocators type aware, we need to make sure that the returned type from the allocation matches the type of the variable being assigned. (Before, the allocator would always return "void *", which can be implicitly cast to any pointer type.)
This is allocating a copy of rockchip_dais, which is an array of struct snd_soc_dai_link, but the size was taken from the whole array, which would make the allocation type a pointer to the array rather than the "struct snd_soc_dai_link *" being assigned. Allocate ARRAY_SIZE-many entries instead. The resulting allocation size is the same.
Build tested ARCH=x86_64 allmodconfig with GCC 16.2.0:sound/soc/rockchip/rk3399_gru_sound.o
---
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
--- sound/soc/rockchip/rk3399_gru_sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/rockchip/rk3399_gru_sound.c +2 -2
@@ -505,8 +505,8 @@ static int rockchip_sound_of_parse_dais(struct device *dev,int i, index;int num_routes; - card->dai_link =devm_kzalloc (dev,sizeof (rockchip_dais), -GFP_KERNEL ); + card->dai_link =devm_kcalloc (dev,ARRAY_SIZE (rockchip_dais), +sizeof (*card->dai_link),GFP_KERNEL );if (!card->dai_link)return -ENOMEM ;
Signature · 1 line
2.34.1
Mark Brown
maintainerQuoted 1 line · Kees Cook
ASoC: rockchip:
rk3399_gru_sound: Allocatedai_linkwithARRAY_SIZE()
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/1] ASoC: rockchip: rk3399_gru_sound: Allocate dai_link with ARRAY_SIZE()
https://git.kernel.org/broonie/sound/c/8633243a494b
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