Skip to contentSkip to conversation

ASoC: Intel: avs: Fix kcalloc() sizes

PATCH In review Thorsten Blum 3 participants 3 messages Apr 26, 2025 – May 1, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: avs: Fix kcalloc() sizes

rlist, clist, and slist are allocated using sizeof(pointer) instead of sizeof(*pointer). Fix the allocations by using sizeof(*pointer) and avoid overallocating memory on 64-bit systems.

Fixes f2f847461fb7 ("ASoC: Intel: avs: Constrain path based on BE capabilities")
---
 sound/soc/intel/avs/path.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/avs/path.c +3 -3
index cafb8c6198be..8f1bf8d0af8f 100644
@@ -131,9 +131,9 @@ int avs_path_set_constraint(struct avs_dev *adev, struct avs_tplg_path_template
 	list_for_each_entry(path_template, &template->path_list, node)
 		i++;
 
-	rlist = kcalloc(i, sizeof(rlist), GFP_KERNEL);
-	clist = kcalloc(i, sizeof(clist), GFP_KERNEL);
-	slist = kcalloc(i, sizeof(slist), GFP_KERNEL);
+	rlist = kcalloc(i, sizeof(*rlist), GFP_KERNEL);
+	clist = kcalloc(i, sizeof(*clist), GFP_KERNEL);
+	slist = kcalloc(i, sizeof(*slist), GFP_KERNEL);
 
 	i = 0;
 	list_for_each_entry(path_template, &template->path_list, node) {
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Thorsten Blum

rlist, clist, and slist are allocated using sizeof(pointer) instead of sizeof(*pointer). Fix the allocations by using sizeof(*pointer) and avoid overallocating memory on 64-bit systems.

Fixes f2f847461fb7 ("ASoC: Intel: avs: Constrain path based on BE capabilities")
---
  sound/soc/intel/avs/path.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/avs/path.c +0 -0
index cafb8c6198be..8f1bf8d0af8f 100644
@@ -131,9 +131,9 @@ int avs_path_set_constraint(struct avs_dev *adev, struct avs_tplg_path_template
  	list_for_each_entry(path_template, &template->path_list, node)
  		i++;

sound/soc/intel/avs/path.c int avs_path_set_constraint(struct avs_dev *adev, struct avs_tplg_path_template · line 139

Quoted 10 lines
sound/soc/intel/avs/path.c +3 -3
 
-	rlist = kcalloc(i, sizeof(rlist), GFP_KERNEL);
-	clist = kcalloc(i, sizeof(clist), GFP_KERNEL);
-	slist = kcalloc(i, sizeof(slist), GFP_KERNEL);
+	rlist = kcalloc(i, sizeof(*rlist), GFP_KERNEL);
+	clist = kcalloc(i, sizeof(*clist), GFP_KERNEL);
+	slist = kcalloc(i, sizeof(*slist), GFP_KERNEL);
 
  	i = 0;
  	list_for_each_entry(path_template, &template->path_list, node) {

Of course, thanks!

maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 5 lines · Thorsten Blum

rlist, clist, and slist are allocated using sizeof(pointer) instead of sizeof(*pointer). Fix the allocations by using sizeof(*pointer) and avoid overallocating memory on 64-bit systems.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: Intel: avs: Fix kcalloc() sizes

      commit: d20df86b056b95845f6ed52da1010059202a0c23

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