]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spi: stm32: fix sram pool free in probe error path
authorClément Le Goffic <clement.legoffic@foss.st.com>
Mon, 30 Jun 2025 12:59:23 +0000 (14:59 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 30 Jun 2025 14:59:47 +0000 (15:59 +0100)
Add a test to check whether the sram_pool is NULL before freeing it.

Fixes: d17dd2f1d8a1 ("spi: stm32: use STM32 DMA with STM32 MDMA to enhance DDR use")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Clément Le Goffic <clement.legoffic@foss.st.com>
Link: https://patch.msgid.link/20250630-spi-fix-v2-1-4680939e2a3e@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-stm32.c

index 3d20f09f1ae7edbfd94d4b830ca7c33b127284a9..858470a2cab52591a04841ba5ef08174b973895e 100644 (file)
@@ -2486,7 +2486,9 @@ err_pm_disable:
        if (spi->mdma_rx)
                dma_release_channel(spi->mdma_rx);
 err_pool_free:
-       gen_pool_free(spi->sram_pool, (unsigned long)spi->sram_rx_buf, spi->sram_rx_buf_size);
+       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);