Unverified Commit f4d8438e authored by Clément Le Goffic's avatar Clément Le Goffic Committed by Mark Brown
Browse files

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: d17dd2f1 ("spi: stm32: use STM32 DMA with STM32 MDMA to enhance DDR use")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Acked-by: default avatarAlain Volmat <alain.volmat@foss.st.com>
Signed-off-by: default avatarClé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: default avatarMark Brown <broonie@kernel.org>
parent 7e1c28fb
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2486,7 +2486,9 @@ static int stm32_spi_probe(struct platform_device *pdev)
	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);