* [PATCH] usb: cdnsp: Use common error handling code in cdnsp_segment_alloc()
@ 2026-06-10 11:36 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2026-06-10 11:36 UTC (permalink / raw)
To: linux-usb, Greg Kroah-Hartman, Pawel Laszczak
Cc: LKML, kernel-janitors, Felix Gu, Johan Hovold
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 Jun 2026 13:30:08 +0200
Use an additional label so that a bit of exception handling can be better
reused at the end of this function implementation.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/usb/cdns3/cdnsp-mem.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
index 5d8cdc91927d..7696e570f769 100644
--- a/drivers/usb/cdns3/cdnsp-mem.c
+++ b/drivers/usb/cdns3/cdnsp-mem.c
@@ -40,10 +40,8 @@ static struct cdnsp_segment *cdnsp_segment_alloc(struct cdnsp_device *pdev,
return NULL;
seg->trbs = dma_pool_zalloc(pdev->segment_pool, flags, &dma);
- if (!seg->trbs) {
- kfree(seg);
- return NULL;
- }
+ if (!seg->trbs)
+ goto free_seg;
if (max_packet) {
seg->bounce_buf = kzalloc(max_packet, flags | GFP_DMA);
@@ -63,6 +61,7 @@ static struct cdnsp_segment *cdnsp_segment_alloc(struct cdnsp_device *pdev,
free_dma:
dma_pool_free(pdev->segment_pool, seg->trbs, dma);
+free_seg:
kfree(seg);
return NULL;
--
2.54.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-10 11:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-10 11:36 [PATCH] usb: cdnsp: Use common error handling code in cdnsp_segment_alloc() Markus Elfring
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®