Skip to content

Commit 99d00a9

Browse files
Xu Raogregkh
authored andcommitted
xhci: sideband: fix ring sg table pages leak
commit 49f6e3c upstream. 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: de66754 ("xhci: sideband: add initial api to register a secondary interrupter entity") Cc: stable <stable@kernel.org> Signed-off-by: Xu Rao <raoxu@uniontech.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20260703144033.483286-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f905861 commit 99d00a9

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/usb/host/xhci-sideband.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ xhci_ring_to_sgtable(struct xhci_sideband *sb, struct xhci_ring *ring)
5858
if (sg_alloc_table_from_pages(sgt, pages, n_pages, 0, sz, GFP_KERNEL))
5959
goto err;
6060

61+
kvfree(pages);
62+
6163
/*
6264
* Save first segment dma address to sg dma_address field for the sideband
6365
* client to have access to the IOVA of the ring.

0 commit comments

Comments
 (0)