* [PATCH] dmaengine: jz4780: fix resource leaks on error exit return
@ 2016-09-29 17:45 Colin King
2016-09-30 17:52 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2016-09-29 17:45 UTC (permalink / raw)
To: Zubair Lutfullah Kakakhel, Vinod Koul, Dan Williams, dmaengine
Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
In two cases when jz4780_dma_setup_hwdesc fails, there is a memory
leak on the allocated desc and associated DMA pools on the error
exit return path. Fix this by free'ing the resources before
returning.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/dma/dma-jz4780.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
index c36c14c..7373b7a 100644
--- a/drivers/dma/dma-jz4780.c
+++ b/drivers/dma/dma-jz4780.c
@@ -324,8 +324,10 @@ static struct dma_async_tx_descriptor *jz4780_dma_prep_slave_sg(
sg_dma_address(&sgl[i]),
sg_dma_len(&sgl[i]),
direction);
- if (err < 0)
+ if (err < 0) {
+ jz4780_dma_desc_free(&jzchan->desc->vdesc);
return NULL;
+ }
desc->desc[i].dcm |= JZ_DMA_DCM_TIE;
@@ -368,8 +370,10 @@ static struct dma_async_tx_descriptor *jz4780_dma_prep_dma_cyclic(
for (i = 0; i < periods; i++) {
err = jz4780_dma_setup_hwdesc(jzchan, &desc->desc[i], buf_addr,
period_len, direction);
- if (err < 0)
+ if (err < 0) {
+ jz4780_dma_desc_free(&jzchan->desc->vdesc);
return NULL;
+ }
buf_addr += period_len;
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: jz4780: fix resource leaks on error exit return
2016-09-29 17:45 [PATCH] dmaengine: jz4780: fix resource leaks on error exit return Colin King
@ 2016-09-30 17:52 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2016-09-30 17:52 UTC (permalink / raw)
To: Colin King
Cc: Zubair Lutfullah Kakakhel, Dan Williams, dmaengine, linux-kernel
On Thu, Sep 29, 2016 at 06:45:05PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In two cases when jz4780_dma_setup_hwdesc fails, there is a memory
> leak on the allocated desc and associated DMA pools on the error
> exit return path. Fix this by free'ing the resources before
> returning.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-30 17:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-29 17:45 [PATCH] dmaengine: jz4780: fix resource leaks on error exit return Colin King
2016-09-30 17:52 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).