Skip to content

Commit 5340259

Browse files
outman119broonie
authored andcommitted
spi: stm32-ospi: Fix DMA channel leak on stm32_ospi_dma_setup() failure
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: e35a760 ("spi: stm32-ospi: Set DMA maxburst dynamically") Signed-off-by: Felix Gu <ustc.gu@gmail.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20260329-stm32-ospi-v1-2-142122466412@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 5a570c8 commit 5340259

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/spi/spi-stm32-ospi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ static int stm32_ospi_probe(struct platform_device *pdev)
928928
dma_cfg.dst_addr = ospi->regs_phys_base + OSPI_DR;
929929
ret = stm32_ospi_dma_setup(ospi, &dma_cfg);
930930
if (ret)
931-
return ret;
931+
goto err_dma_free;
932932

933933
mutex_init(&ospi->lock);
934934

@@ -980,6 +980,7 @@ static int stm32_ospi_probe(struct platform_device *pdev)
980980
err_pm_enable:
981981
pm_runtime_force_suspend(ospi->dev);
982982
mutex_destroy(&ospi->lock);
983+
err_dma_free:
983984
if (ospi->dma_chtx)
984985
dma_release_channel(ospi->dma_chtx);
985986
if (ospi->dma_chrx)

0 commit comments

Comments
 (0)