usb: cdnsp: Use common error handling code in cdnsp_segment_alloc()
Subsystems (3)
PATCH 1/1 usb: cdnsp: Use common error handling code in cdnsp_segment_alloc()
From: Markus Elfring <[email protected]>
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 <[email protected]>
--- drivers/usb/cdns3/cdnsp-mem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/cdns3/cdnsp-mem.c +3 -4
@@ -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 ;
Signature · 1 line
2.54.0