* [RESEND PATCH] xhci: sideband: fix ring sg table pages leak
@ 2026-06-10 9:38 raoxu
2026-06-11 13:55 ` Mathias Nyman
0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-06-10 9:38 UTC (permalink / raw)
To: mathias.nyman; +Cc: gregkh, linux-usb, linux-kernel, raoxu
From: Xu Rao <raoxu@uniontech.com>
xhci_ring_to_sgtable() allocates a temporary pages array and
uses it to build the returned sg_table with
sg_alloc_table_from_pages().
The error paths free the pages array, but the success path
returns the sg_table without freeing it. This leaks the temporary
array every time a sideband client gets an endpoint or event ring
buffer.
Free the pages array after sg_alloc_table_from_pages() succeeds.
The returned sg_table has its own scatterlist entries and does not
depend on the temporary array after construction.
Fixes: de66754e9f80 ("xhci: sideband: add initial api to register a secondary interrupter entity")
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
drivers/usb/host/xhci-sideband.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideband.c
index 23153e136d4b..a5deeee4d5dc 100644
--- a/drivers/usb/host/xhci-sideband.c
+++ b/drivers/usb/host/xhci-sideband.c
@@ -58,6 +58,8 @@ xhci_ring_to_sgtable(struct xhci_sideband *sb, struct xhci_ring *ring)
if (sg_alloc_table_from_pages(sgt, pages, n_pages, 0, sz, GFP_KERNEL))
goto err;
+ kvfree(pages);
+
/*
* Save first segment dma address to sg dma_address field for the sideband
* client to have access to the IOVA of the ring.
--
2.50.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RESEND PATCH] xhci: sideband: fix ring sg table pages leak
2026-06-10 9:38 [RESEND PATCH] xhci: sideband: fix ring sg table pages leak raoxu
@ 2026-06-11 13:55 ` Mathias Nyman
0 siblings, 0 replies; 2+ messages in thread
From: Mathias Nyman @ 2026-06-11 13:55 UTC (permalink / raw)
To: raoxu, mathias.nyman; +Cc: gregkh, linux-usb, linux-kernel
On 6/10/26 12:38, raoxu wrote:
> From: Xu Rao <raoxu@uniontech.com>
>
> xhci_ring_to_sgtable() allocates a temporary pages array and
> uses it to build the returned sg_table with
> sg_alloc_table_from_pages().
>
> The error paths free the pages array, but the success path
> returns the sg_table without freeing it. This leaks the temporary
> array every time a sideband client gets an endpoint or event ring
> buffer.
>
> Free the pages array after sg_alloc_table_from_pages() succeeds.
> The returned sg_table has its own scatterlist entries and does not
> depend on the temporary array after construction.
>
> Fixes: de66754e9f80 ("xhci: sideband: add initial api to register a secondary interrupter entity")
>
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
> ---
> drivers/usb/host/xhci-sideband.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideband.c
> index 23153e136d4b..a5deeee4d5dc 100644
> --- a/drivers/usb/host/xhci-sideband.c
> +++ b/drivers/usb/host/xhci-sideband.c
> @@ -58,6 +58,8 @@ xhci_ring_to_sgtable(struct xhci_sideband *sb, struct xhci_ring *ring)
> if (sg_alloc_table_from_pages(sgt, pages, n_pages, 0, sz, GFP_KERNEL))
> goto err;
>
> + kvfree(pages);
> +
> /*
> * Save first segment dma address to sg dma_address field for the sideband
> * client to have access to the IOVA of the ring.
> --
> 2.50.1
>
Thanks
Adding to queue,
will send forward after 7.2-rc1
-Mathias
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-11 13:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-10 9:38 [RESEND PATCH] xhci: sideband: fix ring sg table pages leak raoxu
2026-06-11 13:55 ` Mathias Nyman
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®