diff options
author | Colin Ian King <colin.king@canonical.com> | 2016-09-29 18:45:05 +0100 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2016-09-30 23:22:26 +0530 |
commit | fc878efe84c342441706fcdf776e08fe455fe9c1 (patch) | |
tree | 659ea88f0bd11b6b6afea75c365eee1b422e6953 /drivers/dma | |
parent | 9f0df936b1b93a7fab5b9ed73009f43369c121ea (diff) | |
download | linux-fc878efe84c342441706fcdf776e08fe455fe9c1.tar.bz2 |
dmaengine: jz4780: fix resource leaks on error exit return
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>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/dma-jz4780.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c index dade7c47ff18..27e93368b62c 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; |