mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] spi: ep93xx: fix double-free of zeropage on DMA setup failure
@ 2026-05-29 15:31 Felix Gu
  2026-06-08 18:03 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-05-29 15:31 UTC (permalink / raw)
  To: Mark Brown, H Hartley Sweeten, Grant Likely, Vinod Koul, Mika Westerberg
  Cc: linux-spi, linux-kernel, Felix Gu

If DMA setup fails after allocating the zeropage, the error path frees
the page but leaves espi->zeropage dangling. A subsequent call to
ep93xx_spi_release_dma() sees the non-NULL pointer and frees the page
again.

Clear the pointer after freeing in the error path of
ep93xx_spi_setup_dma().

Fixes: 626a96db1169 ("spi/ep93xx: add DMA support")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/spi/spi-ep93xx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index ea610b0537a9..bf389d7590d3 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -600,6 +600,7 @@ static int ep93xx_spi_setup_dma(struct device *dev, struct ep93xx_spi *espi)
 	espi->dma_rx = NULL;
 fail_free_page:
 	free_page((unsigned long)espi->zeropage);
+	espi->zeropage = NULL;
 
 	return ret;
 }

---
base-commit: f7af91adc230aa99e23330ecf85bc9badd9780ad
change-id: 20260529-ep93xx-8ac307cb5434

Best regards,
--  
Felix Gu <ustc.gu@gmail.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-09  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-29 15:31 [PATCH] spi: ep93xx: fix double-free of zeropage on DMA setup failure Felix Gu
2026-06-08 18:03 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®