]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xhci: sideband: fix ring sg table pages leak
authorXu Rao <raoxu@uniontech.com>
Fri, 3 Jul 2026 14:40:32 +0000 (17:40 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jul 2026 11:38:24 +0000 (13:38 +0200)
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")
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>
drivers/usb/host/xhci-sideband.c

index 23153e136d4b842b7740453d07bf9b6a713b7d7e..a5deeee4d5dce4e568194d356dae529ec9d54a0c 100644 (file)
@@ -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.