dmaengine: ti: k3-udma: Use common error handling code in udma_prep_slave_sg_pkt()
Subsystems (3)
PATCH 1/1 dmaengine: ti: k3-udma: Use common error handling code in udma_prep_slave_sg_pkt()
From: Markus Elfring <[email protected]>
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.
--- drivers/dma/ti/k3-udma.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/dma/ti/k3-udma.c +2 -4
@@ -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 ;
Signature · 1 line
2.54.0
[email protected]
AI reviewThank 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…
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 <[email protected]>
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.
Quoted 4 lines
drivers/dma/ti/k3-udma.c +0
-0
[ ... ]
drivers/dma/ti/k3-udma.c udma_prep_slave_sg_pkt(struct udma_chan *uc, struct scatterlist *sgl, · line 3309
Quoted 5 lines
drivers/dma/ti/k3-udma.c +1
-0@@ -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?
Quoted 3 lines
drivers/dma/ti/k3-udma.c +0
-0udma_free_hwdesc (uc, d);kfree (d);return NULL ;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1