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

Olivier MOYSAN olivier.moysan at foss.st.com
Thu Nov 5 15:59:23 CET 2026


Hi Wentao,

On 11/4/26 03:40, Wentao Liang wrote:
> 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: 03e4d5d56fa5 ("ASoC: stm32: Add SPDIFRX support")
> 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>
> ---
>   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;
>   };

Thanks for the patch. The patch itself looks good to me.

Just one remark regarding Fixes reference in commit message.
In initial commit 03e4d5d56fa5 the channel was released before setting 
ctrl_chan to NULL.

This was change through commit 98c8dc2fd59f. So it is more relevant to 
refer this commit:
Fixes: 98c8dc2fd59f ("ASoC: stm32: spdifrx: fix control DMA error 
management")

With this change you can add my Reviewed-by.

BRs
Olivier


More information about the Linux-stm32 mailing list