All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: omap2-mcspi: fix memory leak on slave transfer abort
@ 2023-07-11  9:04 Ruben Vandamme
  0 siblings, 0 replies; only message in thread
From: Ruben Vandamme @ 2023-07-11  9:04 UTC (permalink / raw)
  To: linux-spi; +Cc: Ruben Vandamme

In case a slave mode transfer is aborted, the scatterlists need
to be freed before exiting the function.

Signed-off-by: Ruben Vandamme <kernel-org-500524@vandamme.email>
---
 drivers/spi/spi-omap2-mcspi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 8331e247bf5c..48800afc35b0 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -514,15 +514,16 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
 	omap2_mcspi_set_dma_req(spi, 1, 1);
 
 	ret = mcspi_wait_for_completion(mcspi, &mcspi_dma->dma_rx_completion);
+
+	for (x = 0; x < nb_sizes; x++)
+		kfree(sg_out[x]);
+
 	if (ret || mcspi->slave_aborted) {
 		dmaengine_terminate_sync(mcspi_dma->dma_rx);
 		omap2_mcspi_set_dma_req(spi, 1, 0);
 		return 0;
 	}
 
-	for (x = 0; x < nb_sizes; x++)
-		kfree(sg_out[x]);
-
 	if (mcspi->fifo_depth > 0)
 		return count;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-11  9:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11  9:04 [PATCH] spi: omap2-mcspi: fix memory leak on slave transfer abort Ruben Vandamme

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.