Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754760AbeAOMkN (ORCPT + 1 other); Mon, 15 Jan 2018 07:40:13 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46586 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934731AbeAOMkK (ORCPT ); Mon, 15 Jan 2018 07:40:10 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Hutchings , Mathias Nyman Subject: [PATCH 4.4 45/87] xhci: Fix ring leak in failure path of xhci_alloc_virt_device() Date: Mon, 15 Jan 2018 13:34:44 +0100 Message-Id: <20180115123353.945747062@linuxfoundation.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180115123349.252309699@linuxfoundation.org> References: <20180115123349.252309699@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings 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 --- This is build-tested only. Ben. drivers/usb/host/xhci-mem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- 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_h 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)