[Linux-stm32] [PATCH v2] ASoC: stm32: spdifrx: keep the control DMA channel on config failure

Wentao Liang vulab at iscas.ac.cn
Fri Nov 6 04:54:34 CET 2026


When dmaengine_slave_config() fails, stm32_spdifrx_dma_ctrl_register()
sets ctrl_chan to NULL and returns the error. The channel obtained from
dma_request_chan() is thus lost, and stm32_spdifrx_probe() calls
stm32_spdifrx_remove() on the error path, which then passes NULL to
dma_release_channel().

Leave ctrl_chan untouched so that the remove path releases the channel.
Its IS_ERR() check already handles the case where dma_request_chan()
failed.

Fixes: 98c8dc2fd59f ("ASoC: stm32: spdifrx: fix control DMA error management")
Cc: stable at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
Changes in v2:
- Point the Fixes tag at 98c8dc2fd59f ("ASoC: stm32: spdifrx: fix
  control DMA error management") rather than at 03e4d5d56fa5
  ("ASoC: stm32: Add SPDIFRX support"). 03e4d5d56fa5 released the
  channel inside stm32_spdifrx_dma_ctrl_register() before clearing
  ctrl_chan; 98c8dc2fd59f dropped that release and left the cleanup to
  the probe error path, which is where the channel leak on
  dmaengine_slave_config() failure was introduced. Noticed by Olivier
  Moysan.
- Link to v1: https://lore.kernel.org/all/20261104024051.1508703-1-vulab@iscas.ac.cn/

 sound/soc/stm/stm32_spdifrx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c
index 88863dbd05d9..ce75929daf73 100644
--- a/sound/soc/stm/stm32_spdifrx.c
+++ b/sound/soc/stm/stm32_spdifrx.c
@@ -425,10 +425,8 @@ static int stm32_spdifrx_dma_ctrl_register(struct device *dev,
 
 	ret = dmaengine_slave_config(spdifrx->ctrl_chan,
 				     &spdifrx->slave_config);
-	if (ret < 0) {
+	if (ret < 0)
 		dev_err(dev, "dmaengine_slave_config returned error %d\n", ret);
-		spdifrx->ctrl_chan = NULL;
-	}
 
 	return ret;
 };
-- 
2.34.1



More information about the Linux-stm32 mailing list