]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: soc-core: Pre-check zero CPU/codec DAIs, handle early rtd->dais alloc failure
authorjempty.liang <imntjempty@163.com>
Wed, 19 Nov 2025 10:11:16 +0000 (10:11 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 19 Nov 2025 11:29:49 +0000 (11:29 +0000)
This commit adds a pre-check in ASoC to ensure there are non-zero CPU or
codec DAIs. It also handles early failure of memory allocation for
rtd->dais by going to the cleanup path, preventing potential issues
from invalid configurations or out-of-memory situations.

Signed-off-by: jempty.liang <imntjempty@163.com>
Link: https://patch.msgid.link/20251119101116.78676-1-imntjempty@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index 4297cc27005c145d4104124dd3bf363dd4e0d09d..e4b21bf39e59f611aad4c8da1bc4a38c5078d17d 100644 (file)
@@ -545,6 +545,11 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
        dev_set_drvdata(dev, rtd);
        INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
 
+       if ((dai_link->num_cpus + dai_link->num_codecs) == 0) {
+               dev_err(dev, "ASoC: it has no CPU or codec DAIs\n");
+               goto free_rtd;
+       }
+
        /*
         * for rtd->dais
         */