Re: [PATCH] usb: cdnsp: fix stream context array leak in cdnsp_alloc_stream_info()
From: Peter Chen
Date: Mon Jun 22 2026 - 06:50:46 EST
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@xxxxxxxxxxxxxxx
> Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx>
Acked-by: Peter Chen <peter.chen@xxxxxxxxxx>
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