From patchwork Sat Oct 22 07:25:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1104863wrr; Sat, 22 Oct 2022 01:33:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4KDQ1eMld2eDQc7GChjhQfpV74n+RFUqLjikxQqH71LXnShpto/gUI8phVAjzKoUI7yhhT X-Received: by 2002:a63:9a11:0:b0:46e:dbd3:413 with SMTP id o17-20020a639a11000000b0046edbd30413mr1594523pge.240.1666427612610; Sat, 22 Oct 2022 01:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427612; cv=none; d=google.com; s=arc-20160816; b=MsiHPxd0ceshLcomgwfFj7w2Vi07W+BSExFPfAQciORvSzcM02gXsHPqJ6OPVRk1F3 1VkG/6rOAjU9/4hfJEX/yWMyS+hvcKY0dvi1JOWyLdC+up6iMklenwvr08khTmW3OBvj TTeq/WEEkskT3Gj5AAzFbi8IffPViHBhxlbZlSr8ovA2t9Adp3gWwYiTnZaWs9gDUzvo 2cFYOxhWTpbc9oX6M3GG0MP2d9yePE7QMCHV2t4w3SrTfB/k4xS1PFNEB16zZcqjLsQw OzgUxCNKIkvDw449rn/s8njaqYbNBYIdqM78U9vcWhgaFcWjSg1GfEDOdJE9HaEQaMOk 1XaQ== 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=XuT5TTyckHEg+/1UkDNmqg7ZAbsohqsMt1/5UEYwdfk=; b=gL/Y3GFgJiYnF5oM44Xhp3w2O/pPrZ2qeeAPpU0Ts1/Tr6R4IAjyQp2rDr+2B4VGvX LiRngHvoYoGOFzeX6f5xRStA0KsboyDa9LJUVraLx02oiu9o6uH6GCKumUdHi5zEacSu noNtArldQTFam2Q0yBuFH9RLZdaSTs2LdSejAM8OHgY905q6UfLq7a9POvG/ZYs+jExN JsB1hPva6RIgtuGb8+M3ryYm2u94BWr6pM20VuXyAH3ukfp0XP0xs0Bgjk5/+yCGO0dO 3KnLmtsABKxh5HPXqR3vSU3qBdvi1C25Bo8ZGw62/MTHFrJPpq2v5Z419MG+O9/ETEOm M3TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Srx8d79V; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 8-20020a631948000000b00462ed110adbsi30317244pgz.316.2022.10.22.01.33.20; Sat, 22 Oct 2022 01:33:32 -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=Srx8d79V; 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 S233580AbiJVISX (ORCPT + 99 others); Sat, 22 Oct 2022 04:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234033AbiJVIP6 (ORCPT ); Sat, 22 Oct 2022 04:15:58 -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 C210F2DB796; Sat, 22 Oct 2022 00:56:51 -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 B893460AE6; Sat, 22 Oct 2022 07:54:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A69B5C433D6; Sat, 22 Oct 2022 07:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425271; bh=UIhXXYdwIpBrrDXc+TJvtBLDWPr6Ak8cvZrM8faBrUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Srx8d79VdB31oyNr+goEWWA7w7yS4X9M22bDvetjmL8nFTeEcULAEF3qw1dhZ6Oz9 8puIMnLAfZwuheTg9up+BwEd7sL97rc2MudOK9Dxt/LxRF6Zg/PKVRXLyBCy30W261 smSoI9kvm5QvGLYO64AaxyLoS+LL2DHc202ZpmQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Sasha Levin Subject: [PATCH 5.19 446/717] usb: dwc3: core: fix some leaks in probe Date: Sat, 22 Oct 2022 09:25:25 +0200 Message-Id: <20221022072518.008482544@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747375999967732014?= X-GMAIL-MSGID: =?utf-8?q?1747375999967732014?= From: Dan Carpenter [ Upstream commit 2a735e4b5580a2a6bbd6572109b4c4f163c57462 ] The dwc3_get_properties() function calls: dwc->usb_psy = power_supply_get_by_name(usb_psy_name); so there is some additional clean up required on these error paths. Fixes: 6f0764b5adea ("usb: dwc3: add a power supply for current control") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/YyxFYFnP53j9sCg+@kili Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc3/core.c | 58 +++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index ebf3afad378b..2419ef828f9b 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1678,8 +1678,10 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_get_properties(dwc); dwc->reset = devm_reset_control_array_get_optional_shared(dev); - if (IS_ERR(dwc->reset)) - return PTR_ERR(dwc->reset); + if (IS_ERR(dwc->reset)) { + ret = PTR_ERR(dwc->reset); + goto put_usb_psy; + } if (dev->of_node) { /* @@ -1689,45 +1691,57 @@ static int dwc3_probe(struct platform_device *pdev) * check for them to retain backwards compatibility. */ dwc->bus_clk = devm_clk_get_optional(dev, "bus_early"); - if (IS_ERR(dwc->bus_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), - "could not get bus clock\n"); + if (IS_ERR(dwc->bus_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), + "could not get bus clock\n"); + goto put_usb_psy; + } if (dwc->bus_clk == NULL) { dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk"); - if (IS_ERR(dwc->bus_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), - "could not get bus clock\n"); + if (IS_ERR(dwc->bus_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), + "could not get bus clock\n"); + goto put_usb_psy; + } } dwc->ref_clk = devm_clk_get_optional(dev, "ref"); - if (IS_ERR(dwc->ref_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), - "could not get ref clock\n"); + if (IS_ERR(dwc->ref_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), + "could not get ref clock\n"); + goto put_usb_psy; + } if (dwc->ref_clk == NULL) { dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk"); - if (IS_ERR(dwc->ref_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), - "could not get ref clock\n"); + if (IS_ERR(dwc->ref_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), + "could not get ref clock\n"); + goto put_usb_psy; + } } dwc->susp_clk = devm_clk_get_optional(dev, "suspend"); - if (IS_ERR(dwc->susp_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), - "could not get suspend clock\n"); + if (IS_ERR(dwc->susp_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), + "could not get suspend clock\n"); + goto put_usb_psy; + } if (dwc->susp_clk == NULL) { dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk"); - if (IS_ERR(dwc->susp_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), - "could not get suspend clock\n"); + if (IS_ERR(dwc->susp_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), + "could not get suspend clock\n"); + goto put_usb_psy; + } } } ret = reset_control_deassert(dwc->reset); if (ret) - return ret; + goto put_usb_psy; ret = dwc3_clk_enable(dwc); if (ret) @@ -1827,7 +1841,7 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_clk_disable(dwc); assert_reset: reset_control_assert(dwc->reset); - +put_usb_psy: if (dwc->usb_psy) power_supply_put(dwc->usb_psy);