]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xhci: Fix ring leak in failure path of xhci_alloc_virt_device()
authorBen Hutchings <ben.hutchings@codethink.co.uk>
Thu, 11 Jan 2018 17:01:36 +0000 (17:01 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 8 Apr 2018 09:49:44 +0000 (11:49 +0200)
This is a stable-only fix for the backport of commit 5d9b70f7d52e
("xhci: Don't add a virt_dev to the devs array before it's fully
allocated").

In branches that predate commit c5628a2af83a ("xhci: remove endpoint
ring cache") there is an additional failure path in
xhci_alloc_virt_device() where ring cache allocation fails, in
which case we need to free the ring allocated for endpoint 0.

Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Wang Han <wanghan1995315@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-mem.c

index b72263661d0420cfd97f99953906502f41fd7060..76a5f56130bd159476a2c11f0f580266a67ec896 100644 (file)
@@ -1032,7 +1032,8 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
 
        return 1;
 fail:
-
+       if (dev->eps[0].ring)
+               xhci_ring_free(xhci, dev->eps[0].ring);
        if (dev->in_ctx)
                xhci_free_container_ctx(xhci, dev->in_ctx);
        if (dev->out_ctx)