ASoC: soc-core.c: Skip dummy codec when adding platforms
authorChancel Liu <chancel.liu@nxp.com>
Tue, 5 Mar 2024 06:56:06 +0000 (15:56 +0900)
committerMark Brown <broonie@kernel.org>
Tue, 12 Mar 2024 16:35:04 +0000 (16:35 +0000)
When pcm_runtime is adding platform components it will scan all
registered components. In case of DPCM FE/BE some DAI links will
configure dummy platform. However both dummy codec and dummy platform
are using "snd-soc-dummy" as component->name. Dummy codec should be
skipped when adding platforms otherwise there'll be overflow and UBSAN
complains.

Reported-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Link: https://msgid.link/r/20240305065606.3778642-1-chancel.liu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index 1e94edba12eb85706d0f1f0acf7c75ad3a8249eb..2ec13d1634b636455f51ab541773e5587003e14b 100644 (file)
@@ -1219,6 +1219,9 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
                        if (!snd_soc_is_matching_component(platform, component))
                                continue;
 
+                       if (snd_soc_component_is_dummy(component) && component->num_dai)
+                               continue;
+
                        snd_soc_rtd_add_component(rtd, component);
                }
        }