Re: [PATCH] ASoC: generic: keep fallback dai_name stable across rebind

From: Kuninori Morimoto

Date: Thu Mar 26 2026 - 21:11:28 EST



Hi Cássio

Thank you for your patch

> simple_parse_dai() and graph_util_parse_dai() first try to identify a
> DAI via dai_args. When that works the card can rebind without relying on
> dlc->dai_name.
>
> The fallback path still calls snd_soc_get_dlc(), which returns a
> borrowed dai_name pointer. If the CPU or codec component is unbound
> while the sound card stays registered, the generic card keeps that
> pointer and the next rebind may compare stale memory while matching the
> DAI.
>
> Stage the fallback result in a temporary dai_link_component and move
> only a card-owned copy of dai_name into the live link component. Use
> devm_kstrdup_const() so static names are reused and dynamic ones remain
> valid for the lifetime of the card device.
>
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@xxxxxxxxx>
> ---

It looks good to me.

Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>

1 concern is that this function is using goto, ad your code is fixing
(A) part.

int graph_util_parse_dai(...)
{
...
dai = snd_soc_get_dai_via_args(...);
if (dai) {
...
=> goto parse_dai_end;
}

(A) ...

parse_dai_end:
...
}


I think it is good timing to use if-else here ?

int graph_util_parse_dai(...)
{
...
dai = snd_soc_get_dai_via_args(...);
if (dai) {
...
+ } else {
+ (A) ...
+ }
...
}



Thank you for your help !!

Best regards
---
Kuninori Morimoto