mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: cdnsp: fix stream context array leak in cdnsp_alloc_stream_info()
@ 2026-06-22  5:26 Haoxiang Li
  2026-06-22 10:46 ` Peter Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-06-22  5:26 UTC (permalink / raw)
  To: pawell, gregkh, peter.chen; +Cc: linux-usb, linux-kernel, Haoxiang Li, stable

cdnsp_alloc_stream_info() allocates stream_info->stream_ctx_array with
cdnsp_alloc_stream_ctx(). If a later stream ring allocation or stream
mapping update fails, the error path frees the allocated stream rings
and stream_rings array, but leaves stream_ctx_array allocated.

Free the stream context array before falling through to the stream_rings
cleanup path.

Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
 drivers/usb/cdns3/cdnsp-mem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
index a2a1b21f2ef8..880097f1007d 100644
--- a/drivers/usb/cdns3/cdnsp-mem.c
+++ b/drivers/usb/cdns3/cdnsp-mem.c
@@ -631,6 +631,8 @@ int cdnsp_alloc_stream_info(struct cdnsp_device *pdev,
 		}
 	}
 
+	cdnsp_free_stream_ctx(pdev, pep);
+
 cleanup_stream_rings:
 	kfree(pep->stream_info.stream_rings);
 
-- 
2.25.1


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

* Re: [PATCH] usb: cdnsp: fix stream context array leak in cdnsp_alloc_stream_info()
  2026-06-22  5:26 [PATCH] usb: cdnsp: fix stream context array leak in cdnsp_alloc_stream_info() Haoxiang Li
@ 2026-06-22 10:46 ` Peter Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen @ 2026-06-22 10:46 UTC (permalink / raw)
  To: Haoxiang Li; +Cc: pawell, gregkh, linux-usb, linux-kernel, stable

On 26-06-22 13:26:27, Haoxiang Li wrote:
> cdnsp_alloc_stream_info() allocates stream_info->stream_ctx_array with
> cdnsp_alloc_stream_ctx(). If a later stream ring allocation or stream
> mapping update fails, the error path frees the allocated stream rings
> and stream_rings array, but leaves stream_ctx_array allocated.
> 
> Free the stream context array before falling through to the stream_rings
> cleanup path.
> 
> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>

Acked-by: Peter Chen <peter.chen@kernel.org>

Peter
> ---
>  drivers/usb/cdns3/cdnsp-mem.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
> index a2a1b21f2ef8..880097f1007d 100644
> --- a/drivers/usb/cdns3/cdnsp-mem.c
> +++ b/drivers/usb/cdns3/cdnsp-mem.c
> @@ -631,6 +631,8 @@ int cdnsp_alloc_stream_info(struct cdnsp_device *pdev,
>  		}
>  	}
>  
> +	cdnsp_free_stream_ctx(pdev, pep);
> +
>  cleanup_stream_rings:
>  	kfree(pep->stream_info.stream_rings);
>  
> -- 
> 2.25.1
> 
> 

-- 

Thanks,
Peter Chen

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22  5:26 [PATCH] usb: cdnsp: fix stream context array leak in cdnsp_alloc_stream_info() Haoxiang Li
2026-06-22 10:46 ` Peter Chen

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

Powered by JetHome