* [PATCH] dmaengine: sun4i: fix resource leak on promise allocation failure
@ 2025-12-12 20:50 Osama Abdelkader
0 siblings, 0 replies; only message in thread
From: Osama Abdelkader @ 2025-12-12 20:50 UTC (permalink / raw)
To: Vinod Koul, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
dmaengine, linux-arm-kernel, linux-sunxi, linux-kernel
Cc: Osama Abdelkader
When promise allocation fails in sun4i_dma_prep_dma_cyclic() or
sun4i_dma_prep_slave_sg(), the contract and already-allocated promises
are not freed, causing a resource leak.
Fix this by calling sun4i_dma_free_contract() to properly clean up
all resources before returning NULL on allocation failure.
This addresses the TODO comments that asked whether we should free
everything on error.
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
drivers/dma/sun4i-dma.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c
index 00d2fd38d17f..d81e705ae91f 100644
--- a/drivers/dma/sun4i-dma.c
+++ b/drivers/dma/sun4i-dma.c
@@ -861,7 +861,7 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len,
plength, sconfig, dir);
if (!promise) {
- /* TODO: should we free everything? */
+ sun4i_dma_free_contract(&contract->vd);
return NULL;
}
promise->cfg |= endpoints;
@@ -954,8 +954,10 @@ sun4i_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
sg_dma_len(sg),
sconfig, dir);
- if (!promise)
- return NULL; /* TODO: should we free everything? */
+ if (!promise) {
+ sun4i_dma_free_contract(&contract->vd);
+ return NULL;
+ }
promise->cfg |= endpoints;
promise->para = para;
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-12 20:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-12 20:50 [PATCH] dmaengine: sun4i: fix resource leak on promise allocation failure Osama Abdelkader
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®