Skip to content

Commit f4d8438

Browse files
clegofficbroonie
authored andcommitted
spi: stm32: fix sram pool free in probe error path
Add a test to check whether the sram_pool is NULL before freeing it. Fixes: d17dd2f ("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>
1 parent 7e1c28f commit f4d8438

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/spi/spi-stm32.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,9 @@ static int stm32_spi_probe(struct platform_device *pdev)
24862486
if (spi->mdma_rx)
24872487
dma_release_channel(spi->mdma_rx);
24882488
err_pool_free:
2489-
gen_pool_free(spi->sram_pool, (unsigned long)spi->sram_rx_buf, spi->sram_rx_buf_size);
2489+
if (spi->sram_pool)
2490+
gen_pool_free(spi->sram_pool, (unsigned long)spi->sram_rx_buf,
2491+
spi->sram_rx_buf_size);
24902492
err_dma_release:
24912493
if (spi->dma_tx)
24922494
dma_release_channel(spi->dma_tx);

0 commit comments

Comments
 (0)