[PATCH 1/4] dmaengine: ste_dma40: Fix failed start cleanup

Linus Walleij <[email protected]>
Newsgroups org.kernel.vger.dmaengine
Message-ID <[email protected]>
If d40_start() fails after a queued descriptor has been moved to the
active list, d40_queue_start() currently returns NULL without unwinding
the descriptor state or clearing the channel busy flag.

Fix this pre-existing error path by removing and freeing the descriptor,
clearing the busy flag and returning the error pointer to distinguish the
failure from the no-work case.

Reported-by: [email protected]
Closes: https://lore.kernel.org/dmaengine/[email protected]/
Assisted-by: Codex:gpt-5-5
Signed-off-by: Linus Walleij <[email protected]>
---
 drivers/dma/ste_dma40.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 0d9ffa3e2663..d5837aa0a789 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1531,8 +1531,12 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)
 		/* Start dma job */
 		err = d40_start(d40c);
 
-		if (err)
-			return NULL;
+		if (err) {
+			d40_desc_remove(d40d);
+			d40_desc_free(d40c, d40d);
+			d40c->busy = false;
+			return ERR_PTR(err);
+		}
 	}
 
 	return d40d;

-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.