Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: soc-core: Pre-check zero CPU/codec DAIs, handle early rtd->dais alloc failure

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>

authored by

jempty.liang and committed by
Mark Brown
e2c48498 683c03b9

+5
+5
sound/soc/soc-core.c
··· 545 545 dev_set_drvdata(dev, rtd); 546 546 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); 547 547 548 + if ((dai_link->num_cpus + dai_link->num_codecs) == 0) { 549 + dev_err(dev, "ASoC: it has no CPU or codec DAIs\n"); 550 + goto free_rtd; 551 + } 552 + 548 553 /* 549 554 * for rtd->dais 550 555 */