From f4d8438e6a402ad40cf4ccb6e2d2417d9ed47821 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Le=20Goffic?= Date: Mon, 30 Jun 2025 14:59:23 +0200 Subject: [PATCH] spi: stm32: fix sram pool free in probe error path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Acked-by: Alain Volmat Signed-off-by: Clément Le Goffic Link: https://patch.msgid.link/20250630-spi-fix-v2-1-4680939e2a3e@foss.st.com Signed-off-by: Mark Brown --- drivers/spi/spi-stm32.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 3d20f09f1ae7e..858470a2cab52 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -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); -- 2.47.2