Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754143AbdFSPeI (ORCPT ); Mon, 19 Jun 2017 11:34:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44864 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750733AbdFSPeD (ORCPT ); Mon, 19 Jun 2017 11:34:03 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Bondarenko , Alan Stern Subject: [PATCH 3.18 21/32] usb: core: fix potential memory leak in error path during hcd creation Date: Mon, 19 Jun 2017 23:21:05 +0800 Message-Id: <20170619152036.914738957@linuxfoundation.org> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170619152035.750974520@linuxfoundation.org> References: <20170619152035.750974520@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 Content-Length: 991 Lines: 32 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anton Bondarenko commit 1a744d2eb76aaafb997fda004ae3ae62a1538f85 upstream. Free memory allocated for address0_mutex if allocation of bandwidth_mutex failed. Fixes: feb26ac31a2a ("usb: core: hub: hub_port_init lock controller instead of bus") Signed-off-by: Anton Bondarenko Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2461,6 +2461,7 @@ struct usb_hcd *usb_create_shared_hcd(co hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), GFP_KERNEL); if (!hcd->bandwidth_mutex) { + kfree(hcd->address0_mutex); kfree(hcd); dev_dbg(dev, "hcd bandwidth mutex alloc failed\n"); return NULL;