DMA Engine development
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ti: k3-udma: Use common error handling code in udma_prep_slave_sg_pkt()
@ 2026-06-10 19:47 Markus Elfring
  2026-06-10 19:53 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-06-10 19:47 UTC (permalink / raw)
  To: dmaengine, Frank Li, Peter Ujfalusi, Vinod Koul; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 Jun 2026 21:43:12 +0200

Use an additional label so that a bit of exception handling can be better
reused at the end of an if branch.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ti/k3-udma.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 1cf158eb7bdb..1ee779d73921 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -3270,10 +3270,7 @@ udma_prep_slave_sg_pkt(struct udma_chan *uc, struct scatterlist *sgl,
 		if (!hwdesc->cppi5_desc_vaddr) {
 			dev_err(uc->ud->dev,
 				"descriptor%d allocation failed\n", i);
-
-			udma_free_hwdesc(uc, d);
-			kfree(d);
-			return NULL;
+			goto free_hwdesc;
 		}
 
 		d->residue += sg_len;
@@ -3309,6 +3306,7 @@ udma_prep_slave_sg_pkt(struct udma_chan *uc, struct scatterlist *sgl,
 		dev_err(uc->ud->dev,
 			"%s: Transfer size %u is over the supported 4M range\n",
 			__func__, d->residue);
+free_hwdesc:
 		udma_free_hwdesc(uc, d);
 		kfree(d);
 		return NULL;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dmaengine: ti: k3-udma: Use common error handling code in udma_prep_slave_sg_pkt()
  2026-06-10 19:47 [PATCH] dmaengine: ti: k3-udma: Use common error handling code in udma_prep_slave_sg_pkt() Markus Elfring
@ 2026-06-10 19:53 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-06-10 19:53 UTC (permalink / raw)
  To: Markus Elfring; +Cc: vkoul, dmaengine, Frank.Li

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The error handling label `free_hwdesc` is inappropriately placed inside an unrelated conditional block, creating non-linear control flow.
--

commit 8ea86eb1521c2e6195625764d7c02223ede1fd79
Author: Markus Elfring <elfring@users.sourceforge.net>

dmaengine: ti: k3-udma: Use common error handling code in udma_prep_slave_sg_pkt()

This commit introduces a new goto label to reuse error handling code when
descriptor allocation fails. The cleanup logic is now consolidated to avoid
duplication.

> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> index c964ebfcf3b68..b56ee3ca848ef 100644
> --- a/drivers/dma/ti/k3-udma.c
> +++ b/drivers/dma/ti/k3-udma.c

[ ... ]

> @@ -3309,6 +3306,7 @@ udma_prep_slave_sg_pkt(struct udma_chan *uc, struct scatterlist *sgl,
>  		dev_err(uc->ud->dev,
>  			"%s: Transfer size %u is over the supported 4M range\n",
>  			__func__, d->residue);
> +free_hwdesc:

[Severity: Low]
Does placing this error handling label inside the unrelated residue bounds
check block create confusing control flow?

Jumping into the middle of the if (d->residue >= SZ_4M) block works currently,
but could it silently break the descriptor allocation error path if this
bounds check block is ever modified or removed in the future?

>  		udma_free_hwdesc(uc, d);
>  		kfree(d);
>  		return NULL;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/225b97d8-425c-46ea-bee2-df73753bca8c@web.de?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-10 19:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10 19:47 [PATCH] dmaengine: ti: k3-udma: Use common error handling code in udma_prep_slave_sg_pkt() Markus Elfring
2026-06-10 19:53 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox