Skip to contentSkip to conversation

dma: edma: Fix memory leak

PATCH In review Valentin Ilie 2 participants 2 messages Oct 24, 2013 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma: edma: Fix memory leak

When it fails to allocate a slot, edesc should be free'd before return;

---
 drivers/dma/edma.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/edma.c +1 -0
index 098a8da..79ebac6 100644
@@ -305,6 +305,7 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
 				edma_alloc_slot(EDMA_CTLR(echan->ch_num),
 						EDMA_SLOT_ANY);
 			if (echan->slot[i] < 0) {
+				kfree(edesc);
 				dev_err(dev, "Failed to allocate slot\n");
 				return NULL;
 			}
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 12 lines · Valentin Ilie

When it fails to allocate a slot, edesc should be free'd before return;

---
 drivers/dma/edma.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/edma.c +0 -0
index 098a8da..79ebac6 100644

drivers/dma/edma.c static struct dma_async_tx_descriptor *edma_prep_slave_sg( · line 311

Quoted 7 lines
drivers/dma/edma.c +1 -0
@@ -305,6 +305,7 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
 				edma_alloc_slot(EDMA_CTLR(echan->ch_num),
 						EDMA_SLOT_ANY);
 			if (echan->slot[i] < 0) {
+				kfree(edesc);
 				dev_err(dev, "Failed to allocate slot\n");
 				return NULL;
 			}

Applied along with one more fix on the same line

-><8--
From: Vinod Koul <[email protected]>
Date: Thu, 24 Oct 2013 22:17:50 +0530
Subject: [PATCH] dmaengine: edma: fix another memory leak

commit 4b6271a6 fix a menory leak but one more existed in driver so fix that

---
 drivers/dma/edma.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/dma/edma.c +1 -0
index 134fa96..10b577f 100644
@@ -347,6 +347,7 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
 			ccnt = sg_dma_len(sg) / (acnt * bcnt);
 			if (ccnt > (SZ_64K - 1)) {
 				dev_err(dev, "Exceeded max SG segment size\n");
+				kfree(edesc);
 				return NULL;
 			}
 			cidx = acnt * bcnt;
Signature · 3 lines
1.7.0.4

~Vinod