Skip to contentSkip to conversation

ASoC: simple-card-utils: Avoid over-allocating DLCs

PATCH In review Samuel Holland 3 participants 4 messages Aug 5, 2021 – Aug 6, 2021

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

PATCH 1/1 ASoC: simple-card-utils: Avoid over-allocating DLCs

The allocation of the DAI link components (DLCs) passed the wrong pointer to sizeof. Since simple_dai_props is much larger than snd_soc_dai_link_component, there was no out of bounds access, only wasted memory.

---
 sound/soc/generic/simple-card-utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/generic/simple-card-utils.c +2 -2
index 677f7da93b4b..10c63b73900c 100644
@@ -640,8 +640,8 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 			cnf_num += li->num[i].codecs;
 	}
 
-	dais = devm_kcalloc(dev, dai_num, sizeof(*dais),      GFP_KERNEL);
-	dlcs = devm_kcalloc(dev, dlc_num, sizeof(*dai_props), GFP_KERNEL);
+	dais = devm_kcalloc(dev, dai_num, sizeof(*dais), GFP_KERNEL);
+	dlcs = devm_kcalloc(dev, dlc_num, sizeof(*dlcs), GFP_KERNEL);
 	if (!dais || !dlcs)
 		return -ENOMEM;
 
Signature · 1 line
2.31.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Samuel

Thank you for your patch

Quoted 7 lines

The allocation of the DAI link components (DLCs) passed the wrong pointer to sizeof. Since simple_dai_props is much larger than snd_soc_dai_link_component, there was no out of bounds access, only wasted memory.

---

Wow indeed !
Thank you for your fixup

Fixes f2138aed231c8 ("ASoC: simple-card-utils: enable flexible CPU/Codec/Platform")
Fixes 050c7950fd706 ("ASoC: simple-card-utils: alloc dai_link information for CPU/Codec/Platform")
Quoted 21 lines
 sound/soc/generic/simple-card-utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/generic/simple-card-utils.c +2 -2
index 677f7da93b4b..10c63b73900c 100644
@@ -640,8 +640,8 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 			cnf_num += li->num[i].codecs;
 	}
 
-	dais = devm_kcalloc(dev, dai_num, sizeof(*dais),      GFP_KERNEL);
-	dlcs = devm_kcalloc(dev, dlc_num, sizeof(*dai_props), GFP_KERNEL);
+	dais = devm_kcalloc(dev, dai_num, sizeof(*dais), GFP_KERNEL);
+	dlcs = devm_kcalloc(dev, dlc_num, sizeof(*dlcs), GFP_KERNEL);
 	if (!dais || !dlcs)
 		return -ENOMEM;
 
Signature · 1 line
2.31.1
maintainer
#3 lore raw
In reply to Samuel Holland
Quoted 8 lines · Samuel Holland

The allocation of the DAI link components (DLCs) passed the wrong pointer to sizeof. Since simple_dai_props is much larger than snd_soc_dai_link_component, there was no out of bounds access, only wasted memory.

[...]

Applied to

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

Thanks!

[1/1] ASoC: simple-card-utils: Avoid over-allocating DLCs

      commit: 36a9d79e5e9518dfd9548e3237e7a49464c16922

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