From: Ben Hutchings Date: Thu, 11 Jan 2018 17:01:36 +0000 (+0000) Subject: xhci: Fix ring leak in failure path of xhci_alloc_virt_device() X-Git-Tag: v4.4.112~49 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ae43090f13b7f6b6a8d4f4889727d2db4e81dd8;p=thirdparty%2Fkernel%2Fstable.git xhci: Fix ring leak in failure path of xhci_alloc_virt_device() 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 Cc: Mathias Nyman --- diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index f7481c4e2bc95..d9363713b7f1a 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1071,7 +1071,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)