aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGao Pan <pandy.gao@nxp.com>2016-01-18 02:44:01 -0500
committerMark Brown <broonie@kernel.org>2016-02-18 19:12:52 -0500
commitba4a3550e93415f4ff300810b8d0659949fea193 (patch)
treec00efada7dfe0fc50c1e4d1f6a348245baf18f3a
parent390f0ffe92aea878b763c7fd8afd1dff62e0d20b (diff)
spi: imx: fix spi resource leak with dma transfer
In spi_imx_dma_transfer(), when desc_rx = dmaengine_prep_slave_sg() fails, the context goes to label no_dma and then return. However, the memory allocated for desc_tx has not been freed yet, which leads to resource leak. Signed-off-by: Gao Pan <pandy.gao@nxp.com> Reviewed-by: Fugang Duan <B38611@freescale.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-imx.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 08492d6faa0d..c688efa95e29 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -927,7 +927,7 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
927 tx->sgl, tx->nents, DMA_MEM_TO_DEV, 927 tx->sgl, tx->nents, DMA_MEM_TO_DEV,
928 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 928 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
929 if (!desc_tx) 929 if (!desc_tx)
930 goto no_dma; 930 goto tx_nodma;
931 931
932 desc_tx->callback = spi_imx_dma_tx_callback; 932 desc_tx->callback = spi_imx_dma_tx_callback;
933 desc_tx->callback_param = (void *)spi_imx; 933 desc_tx->callback_param = (void *)spi_imx;
@@ -939,7 +939,7 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
939 rx->sgl, rx->nents, DMA_DEV_TO_MEM, 939 rx->sgl, rx->nents, DMA_DEV_TO_MEM,
940 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 940 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
941 if (!desc_rx) 941 if (!desc_rx)
942 goto no_dma; 942 goto rx_nodma;
943 943
944 desc_rx->callback = spi_imx_dma_rx_callback; 944 desc_rx->callback = spi_imx_dma_rx_callback;
945 desc_rx->callback_param = (void *)spi_imx; 945 desc_rx->callback_param = (void *)spi_imx;
@@ -995,7 +995,9 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
995 995
996 return ret; 996 return ret;
997 997
998no_dma: 998rx_nodma:
999 dmaengine_terminate_all(master->dma_tx);
1000tx_nodma:
999 pr_warn_once("%s %s: DMA not available, falling back to PIO\n", 1001 pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
1000 dev_driver_string(&master->dev), 1002 dev_driver_string(&master->dev),
1001 dev_name(&master->dev)); 1003 dev_name(&master->dev));