]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: stm32: fix rx DMA request error handling
authorAlain Volmat <alain.volmat@foss.st.com>
Thu, 12 Feb 2026 11:49:10 +0000 (12:49 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 23 Feb 2026 12:17:52 +0000 (12:17 +0000)
Avoid trying to release the RX DMA channel when an error occurs
during RX dma_request_chan() call. Instead, jump directly to
release the TX channel, if applicable.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-spi/aYXvY6NH7OlZ-OAF@stanley.mountain/T/#u
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Link: https://patch.msgid.link/20260212-spi-stm32-fix-dma-rx-release-v1-1-53a37c31626b@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-stm32.c

index b99de8c4cc997e676126f60113a74f2ebc21ce5b..c9442326782c240c491e019ecc113142693cf842 100644 (file)
@@ -2502,7 +2502,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
                        spi->dma_rx = NULL;
                } else {
                        dev_err_probe(&pdev->dev, ret, "failed to request rx dma channel\n");
-                       goto err_dma_release;
+                       goto err_dma_tx_release;
                }
        } else {
                ctrl->dma_rx = spi->dma_rx;
@@ -2571,11 +2571,11 @@ err_pool_free:
        if (spi->sram_pool)
                gen_pool_free(spi->sram_pool, (unsigned long)spi->sram_rx_buf,
                              spi->sram_rx_buf_size);
-err_dma_release:
-       if (spi->dma_tx)
-               dma_release_channel(spi->dma_tx);
        if (spi->dma_rx)
                dma_release_channel(spi->dma_rx);
+err_dma_tx_release:
+       if (spi->dma_tx)
+               dma_release_channel(spi->dma_tx);
 err_clk_disable:
        clk_disable_unprepare(spi->clk);