[PATCH] spi: stm32: fix sram pool free in probe error path
Alain Volmat
alain.volmat at foss.st.com
Mon Jun 30 04:47:09 PDT 2025
Hi Clément,
On Mon, Jun 30, 2025 at 10:20:13AM +0200, Clément Le Goffic wrote:
> 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 at linaro.org>
> Signed-off-by: Clément Le Goffic <clement.legoffic at foss.st.com>
> ---
> 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 3d20f09f1ae7..858470a2cab5 100644
> --- a/drivers/spi/spi-stm32.c
> +++ b/drivers/spi/spi-stm32.c
> @@ -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);
>
Looks good to me. Thanks.
Acked-by: Alain Volmat <alain.volmat at foss.st.com>
Regards,
Alain
> ---
> base-commit: 045719b1d0aab98e6abdd7715e8587b997d1cefa
> change-id: 20250630-spi-fix-860416bfb96d
>
> Best regards,
> --
> Clément Le Goffic <clement.legoffic at foss.st.com>
>
More information about the linux-arm-kernel
mailing list