[PATCH] spi: omap2-mcspi: fix memory leak on slave transfer abort

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux