Re: [PATCH] ASoC: soc-core: start the runtime's component count at zero

From: Ryan Brue

Date: Tue Nov 10 2026 - 22:07:38 EST


On 11/10/26 7:18 PM, Ryan Brue wrote:
Since commit 4dd10fbbeb9c ("treewide: Convert devm_kmalloc() family to
the devm_kmalloc_obj() family"), soc_new_pcm_runtime() allocates the
runtime with devm_kzalloc_flex(). Since components[] is
__counted_by(num_components), that also sets num_components to the array's
capacity, but snd_soc_rtd_add_component() treats num_components as the
number of components added so far and appends after it.

Every component is therefore written past the end of the allocation, and
for_each_rtd_components() stops at the first, still NULL, entry, so a
link's components are never found. On an MT8173 board the RT5514 link's
init can no longer route to the codec's AMICL widget and the card fails
to register:

mt8173-mt6391 sound: ASoC: Failed to add route Int Mic -> AMICL(*)
RT5514 Codec: ASoC error (-19): at snd_soc_link_init() on RT5514 Codec

Reset the count after the allocation.

Please disregard this, I didn't see Emanuele's fix for the same bug in for-7.4 as d00ba321499c ("ASoC: soc-core: reset rtd->num_components after allocation").

Apologies,
Ryan