[PATCH v4 02/16] ASoC: amd: acp: fix missing cleanup on devm_kasprintf() failure in legacy SDW machine driver

From: Vijendar Mukunda

Date: Fri Oct 30 2026 - 05:51:01 EST


On devm_kasprintf() failure for the cfg-amp and DMIC components
strings in mc_probe(), the legacy SoundWire machine driver returned
-ENOMEM directly without calling asoc_sdw_mc_dailink_exit_loop(),
leaving device references acquired during soc_card_dai_links_create()
unreleased.

Call asoc_sdw_mc_dailink_exit_loop() before returning -ENOMEM on
both failure paths, consistent with the cleanup already done in
the devm_snd_soc_register_card() failure path.

Fixes: 2981d9b0789c ("ASoC: amd: acp: add soundwire machine driver for legacy stack")
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@xxxxxxx>
---
sound/soc/amd/acp/acp-sdw-legacy-mach.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/amd/acp/acp-sdw-legacy-mach.c b/sound/soc/amd/acp/acp-sdw-legacy-mach.c
index a8b62817b234..bd03789c7849 100644
--- a/sound/soc/amd/acp/acp-sdw-legacy-mach.c
+++ b/sound/soc/amd/acp/acp-sdw-legacy-mach.c
@@ -590,15 +590,19 @@ static int mc_probe(struct platform_device *pdev)

card->components = devm_kasprintf(&pdev->dev, GFP_KERNEL,
" cfg-amp:%d", amp_num);
- if (!card->components)
+ if (!card->components) {
+ asoc_sdw_mc_dailink_exit_loop(card);
return -ENOMEM;
+ }
if (soc_sdw_quirk & ASOC_SDW_ACP_DMIC) {
card->components = devm_kasprintf(&pdev->dev, GFP_KERNEL,
"%s mic:acp-dmic cfg-mics:%d",
card->components,
1);
- if (!card->components)
+ if (!card->components) {
+ asoc_sdw_mc_dailink_exit_loop(card);
return -ENOMEM;
+ }
}

/* Register the card */
--
2.53.0