Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2932959iog; Mon, 20 Jun 2022 07:46:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEe2X2EbtgUrQBVTnnfggkwz/QW9NF4ro9j9QbxrlJaxUqjT74X8K9U/VoHGAtqY+6kOGT X-Received: by 2002:a17:903:1248:b0:168:c5a3:b296 with SMTP id u8-20020a170903124800b00168c5a3b296mr24158385plh.146.1655736378218; Mon, 20 Jun 2022 07:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736378; cv=none; d=google.com; s=arc-20160816; b=gYRd1lJKZGSWyQQpa5WoFCNJGNLoA4A1+7olOU5qxZ5aD6/vNpHyMjeW6v/b2JYJPi h1Boe6vCIro74JzoH+XBKTEuriz4h8SgS54n6dc60m+Nv11MY/Se0c33ooPbhf7KJY+M 7zeiQ34rbwTYu+KG/HVDrBUwwPpUzSr9uUB4KLemtBz1otHjlpKksZvGr4Z7fnn/N6Nx w1BG7kpMXTEhhpS37z9Q+4R+vgN4LFlHaewjBliU5csqTm6nRB3ujPp9U5fyQKbtNTle KPqslrx4Gd0AKqDpPgZqcCbRrzNMBUngCKPXYGAdM+gpW4NDN9qZXzmiJHYRdy/3/4SO Cexg== 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=DLtaVKCm9x7eIMu5VOuT3zxHm4zh6eFUzuEzyaWBTQQ=; b=CtSxiwxAzi7A+eE6gugVSJ4RitDxeFU9IIX7s5XiOnWvtdilA+RtDbUrUY1Xq4fwWm YEELIVPBNvsUjwL6P29M/W7b01owB2w8F/xI6v7Cxs6axNWcy5WT6CJWP1IiZkBvQ1Pm tGPbIWAEsJlv4e9AsvvIABAiv1K+kqBH9ZrYkGrf9GGVRqHP6wETycUYGeTPQcpgS7Dc NPaKYYWLqVxCQloxQbTsQeWADotDyJjWkdxL7MoyxkqdeQVqpO5MkeuPd+jerP0FFM9Q EHEzllxDeSmWBpU0AbmOHnTcP8PiQC3vFWVSFvhDpO+t+jULGPwGRdgr5/5eDk6dNPgJ tB2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zwq3XoJs; 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 b1-20020a170902d50100b0016778c1fb03si19327833plg.15.2022.06.20.07.46.05; Mon, 20 Jun 2022 07:46:18 -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=zwq3XoJs; 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 S244402AbiFTNFQ (ORCPT + 99 others); Mon, 20 Jun 2022 09:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244553AbiFTNDn (ORCPT ); Mon, 20 Jun 2022 09:03:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AA041E3DB; Mon, 20 Jun 2022 05:58:11 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B7AB061449; Mon, 20 Jun 2022 12:58:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C508EC341C6; Mon, 20 Jun 2022 12:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655729890; bh=KJ2SapzxlRMwj2wOaVCg3xVM4XQkTl/+A3xCbWmz0Ww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zwq3XoJsTtp50Jks7sEpSIi/toPXX7nGAUAiNuyAAsOP3jUp1TSmktnyDZAfRGRFQ gwL5V/eDfCrlfyEZdy5mqNJpj10m5aldQgqlZSqrF4i7EzJ5WtxM0J0jS5LTpkETFt ijYG5DoavehZLo2jZ2SW/ucOxbsY1Tlj3cB7qR5o= 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 5.18 107/141] usb: dwc2: Fix memory leak in dwc2_hcd_init Date: Mon, 20 Jun 2022 14:50:45 +0200 Message-Id: <20220620124732.706983940@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124729.509745706@linuxfoundation.org> References: <20220620124729.509745706@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 @@ -5190,7 +5190,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);