Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6146514iog; Thu, 23 Jun 2022 12:18:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u2EFkEkLcPkA4SXm7lKoJbsgTPjn8L3Au1n8gxmgm7SKKwFQDHImuPDWPHAAOQ5cSGL5jk X-Received: by 2002:a05:6a00:1305:b0:512:ebab:3b20 with SMTP id j5-20020a056a00130500b00512ebab3b20mr42323527pfu.82.1656011896755; Thu, 23 Jun 2022 12:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011896; cv=none; d=google.com; s=arc-20160816; b=OVD4aV7fthND+vaCjMuTwmivq4UCQ7ZTCbv+52JT5jY+NhYWuMpgQh9D0fRPL1YFSZ OTnvgHY0ZDcqGLXknycrSWk/ifM45p9pCTsQqpQYsAFQztK0zndVa12zDh/sKGAC4y2i pzk6Xnn+jgy3NBt95rzL6I1O5TGyAkb3BKcJLZ8fbdoEsmuzxmAiwNXtXb4eGaJcaDPd 8pdq4J3A1hPHL5MyLnjpvFuzO7u5KkGA08O0cgPzeoHlaw+MvTj7okN5/yerKs9zrfTK eCT13LwNonw+tUjh5pPS3I5CaUJ+4DUH04mfBpQANAO8/57EEY/lAAya576WmrSEmAdC vOGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n1zG9fDCKNiuZC6GGMUy7xI1TMyCD1bf1uRMULzwmkI=; b=VNFp0i25uptxi0Uc4Pn1yTxi94NKwKn8GXNvsmWhbd5jDPOqrsWV5gYvxzomRn2k4x L52rT16lpxHPDil8Kn0a2bSwIQ1VQtXmiosPkByAv+htDa8nqFWCSfcVPlz1UXdMekia L6y1FFOeiKekdBI7RMKulnyLHNfIDvBl88bg9nP5tpfMuzYUioD0IKUD6Xr0AEMShuj9 Dej8zUsUk2eacH0p/OO/A4o7M95JHVtxie3MFI0S/hcfmux4wYcQFYd9dKyUi/puuH+o lOCSleBp5lYKNL6A2PSD6TOxX+W/tcvTbEvAp3WjaSCHtaVGWuZjHcvNpIpog9AKpiih YeAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ir5DKmB3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a631358000000b003fae815a76fsi27019497pgt.352.2022.06.23.12.18.05; Thu, 23 Jun 2022 12:18:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ir5DKmB3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235546AbiFWSVV (ORCPT + 99 others); Thu, 23 Jun 2022 14:21:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237155AbiFWSRy (ORCPT ); Thu, 23 Jun 2022 14:17:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27D62AD9D8; Thu, 23 Jun 2022 10:24:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 90615B824B9; Thu, 23 Jun 2022 17:24:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6E10C341C4; Thu, 23 Jun 2022 17:24:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005054; bh=z3dWjacBiq9mlhDkLRWIo7yL8nIZCd3pFPwhVEm89nY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ir5DKmB3lafIJjrNFVtXnF4Hyg5yfM828OuuyhE0+axCmTvRaUueIrPXQXKQl9/g4 PR2wc8Lw936Gw7Jd4uxyuXs8L3RAMdMCCogoI3N7ApattpXMShNfBzjRt2fu463hcV I48wpCiLp29n5GVECAknbWGWTjYR0v0XVPtxCgnY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Minas Harutyunyan , Miaoqian Lin Subject: [PATCH 4.19 214/234] usb: dwc2: Fix memory leak in dwc2_hcd_init Date: Thu, 23 Jun 2022 18:44:41 +0200 Message-Id: <20220623164349.106846277@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin commit 3755278f078460b021cd0384562977bf2039a57a upstream. usb_create_hcd will alloc memory for hcd, and we should call usb_put_hcd to free it when platform_get_resource() fails to prevent memory leak. goto error2 label instead error1 to fix this. Fixes: 856e6e8e0f93 ("usb: dwc2: check return value after calling platform_get_resource()") Cc: stable Acked-by: Minas Harutyunyan Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220530085413.44068-1-linmq006@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5236,7 +5236,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hso res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { retval = -EINVAL; - goto error1; + goto error2; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res);