[PATCH 1/2] ASoC: soc-core: copy the DAI link names into the card
From: Tyler Baker
Date: Fri Nov 06 2026 - 00:48:10 EST
snd_soc_of_get_dai_link_codecs() and snd_soc_of_get_dai_link_cpus()
keep a DAI name owned by the component, which is freed when the
component unbinds, so the card cannot bind again afterwards.
Copy the name onto the card device, as simple-card and audio-graph-card
do since commit aa173b70d372 ("ASoC: generic: keep fallback dai_name
stable across rebind").
Fixes: e894efef9ac7 ("ASoC: core: add support to card rebind")
Fixes: 900dedd7e47c ("ASoC: Introduce snd_soc_of_get_dai_link_cpus")
Signed-off-by: Tyler Baker <tyler.baker@xxxxxxxxxxxxxxxx>
---
sound/soc/soc-core.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f33bece378b61..0e62965e35aaa 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3253,6 +3253,18 @@ void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link)
}
EXPORT_SYMBOL_GPL(snd_soc_of_put_dai_link_codecs);
+/* dai_name belongs to the component, which can unbind before the card. */
+static int snd_soc_of_dup_dai_name(struct device *dev,
+ struct snd_soc_dai_link_component *dlc)
+{
+ if (!dlc->dai_name)
+ return 0;
+
+ dlc->dai_name = devm_kstrdup_const(dev, dlc->dai_name, GFP_KERNEL);
+
+ return dlc->dai_name ? 0 : -ENOMEM;
+}
+
/*
* snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree
* @dev: Card device
@@ -3282,6 +3294,8 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
/* Parse the list */
for_each_link_codecs(dai_link, index, component) {
ret = snd_soc_of_get_dlc(of_node, NULL, component, index);
+ if (!ret)
+ ret = snd_soc_of_dup_dai_name(dev, component);
if (ret)
goto err;
}
@@ -3337,6 +3351,8 @@ int snd_soc_of_get_dai_link_cpus(struct device *dev,
/* Parse the list */
for_each_link_cpus(dai_link, index, component) {
ret = snd_soc_of_get_dlc(of_node, NULL, component, index);
+ if (!ret)
+ ret = snd_soc_of_dup_dai_name(dev, component);
if (ret)
goto err;
}
--
2.47.3