[PATCH 2/2] spi: stm32-ospi: Fix DMA channel leak on stm32_ospi_dma_setup() failure

Patrice CHOTARD patrice.chotard at foss.st.com
Sun Mar 29 23:02:50 PDT 2026



On 3/28/26 17:07, Felix Gu wrote:
> When stm32_ospi_dma_setup() fails, the DMA channels allocated by
> stm32_ospi_get_resources() were never released. Add proper cleanup
> in the error path.
> 
> Fixes: e35a7607e05d ("spi: stm32-ospi: Set DMA maxburst dynamically")
> Signed-off-by: Felix Gu <ustc.gu at gmail.com>
> ---
>  drivers/spi/spi-stm32-ospi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
> index 52997c3f7174..34498939bcdf 100644
> --- a/drivers/spi/spi-stm32-ospi.c
> +++ b/drivers/spi/spi-stm32-ospi.c
> @@ -923,7 +923,7 @@ static int stm32_ospi_probe(struct platform_device *pdev)
>  	dma_cfg.dst_addr = ospi->regs_phys_base + OSPI_DR;
>  	ret = stm32_ospi_dma_setup(ospi, &dma_cfg);
>  	if (ret)
> -		return ret;
> +		goto err_dma_free;
>  
>  	mutex_init(&ospi->lock);
>  
> @@ -975,6 +975,7 @@ static int stm32_ospi_probe(struct platform_device *pdev)
>  err_pm_enable:
>  	pm_runtime_force_suspend(ospi->dev);
>  	mutex_destroy(&ospi->lock);
> +err_dma_free:
>  	if (ospi->dma_chtx)
>  		dma_release_channel(ospi->dma_chtx);
>  	if (ospi->dma_chrx)
> 

Hi Felix

Reviewed-by: Patrice Chotard <patrice.chotard at foss.st.com>

Thanks
Patrice



More information about the linux-arm-kernel mailing list