From: "jempty.liang" <imntjempty@163.com>
To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
"jempty.liang" <imntjempty@163.com>
Subject: [PATCH] ASoC: soc-core: Pre-check zero CPU/codec DAIs, handle early rtd->dais alloc failure
Date: Wed, 19 Nov 2025 10:11:16 +0000 [thread overview]
Message-ID: <20251119101116.78676-1-imntjempty@163.com> (raw)
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>
---
sound/soc/soc-core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4297cc27005c..e4b21bf39e59 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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
*/
--
2.25.1
next reply other threads:[~2025-11-19 10:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 10:11 jempty.liang [this message]
2025-11-19 15:30 ` [PATCH] ASoC: soc-core: Pre-check zero CPU/codec DAIs, handle early rtd->dais alloc failure Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251119101116.78676-1-imntjempty@163.com \
--to=imntjempty@163.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox