Re: [PATCH 5.10 070/491] ASoC: core: Exit all links before removing their components

Ben Hutchings
2026-04-14T22:16:05Z

[-- Attachment #1: Type: text/plain, Size: 1953 bytes --]

On Mon, 2026-04-13 at 17:55 +0200, Greg Kroah-Hartman wrote:
> 5.10-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Cezary Rojewski <cezary.rojewski@intel.com>
>
> [ Upstream commit c7eb967d70446971413061effca3226578cb4dab ]

I don't think this change is safe for 5.10.

[...]
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 4294206dff362..562fbc0fb3475 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -962,9 +962,6 @@ void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
>
> lockdep_assert_held(&client_mutex);
>
> - /* release machine specific resources */
> - snd_soc_link_exit(rtd);
> -
> /*
> * Notify the machine driver for extra destruction
> */

snd_soc_remove_pcm_runtime() is called from remove_link() in
soc-topology.c. I might be misunderstanding it, but it seems to free
the structure that snd_soc_link_exit() accesses immediately after
snd_soc_remove_pcm_runtime() returns.

> @@ -1928,6 +1925,9 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
>
> snd_soc_dapm_shutdown(card);
>
> + /* release machine specific resources */
> + for_each_card_rtds(card, rtd)
> + snd_soc_link_exit(rtd);
> /* remove and free each DAI */
> soc_remove_link_dais(card);
> soc_remove_link_components(card);

So it wouldn't be safe to defer snd_soc_link_exit() to here.

After ff9226224437 ("ASoC: topology: Change allocations to resource
managed") upstream that memory is device-managed, making the lifetime of
the link structure long enough for this to be OK. So none of the newer
branches would have this problem.

Ben.

--
Ben Hutchings
The obvious mathematical breakthrough [to break modern encryption]
would be development of an easy way to factor large prime numbers.
- Bill Gates

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]