Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A88F2C433FE for ; Tue, 14 Dec 2021 22:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232975AbhLNWPV (ORCPT ); Tue, 14 Dec 2021 17:15:21 -0500 Received: from hostingweb31-40.netsons.net ([89.40.174.40]:40596 "EHLO hostingweb31-40.netsons.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232252AbhLNWPQ (ORCPT ); Tue, 14 Dec 2021 17:15:16 -0500 Received: from [77.244.183.192] (port=63782 helo=melee.fritz.box) by hostingweb31.netsons.net with esmtpa (Exim 4.94.2) (envelope-from ) id 1mxG4n-000AP5-2s; Tue, 14 Dec 2021 23:15:13 +0100 From: Luca Ceresoli To: linux-pci@vger.kernel.org Cc: Luca Ceresoli , Dan Carpenter , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kishon Vijay Abraham I , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Bjorn Helgaas , Sekhar Nori , kernel test robot Subject: [PATCH 2/2] PCI: dra7xx: Fix clk disabling in some error paths Date: Tue, 14 Dec 2021 23:14:50 +0100 Message-Id: <20211214221450.589884-2-luca@lucaceresoli.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211214221450.589884-1-luca@lucaceresoli.net> References: <20211214221450.589884-1-luca@lucaceresoli.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dra7xx->clk is not disabled+unprepared in some one the error paths, specifically devm_phy_get() fails. Fix by moving the clk_prepare_enable() stanza after all the devm_*() resource grabbing but before all the goto-based error management. This way it is possible to keep the 'return err' without the need to replace it with a new goto statement. Fixes: 5af9405397bf ("PCI: dra7xx: Get an optional clock") Reported-by: Dan Carpenter Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202111301803.NOwoj4Jd-lkp@intel.com/ Signed-off-by: Luca Ceresoli --- drivers/pci/controller/dwc/pci-dra7xx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index 2ccc53869e13..d17cc088d07e 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -748,10 +748,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(dra7xx->clk), "clock request failed"); - ret = clk_prepare_enable(dra7xx->clk); - if (ret) - return ret; - for (i = 0; i < phy_count; i++) { snprintf(name, sizeof(name), "pcie-phy%d", i); phy[i] = devm_phy_get(dev, name); @@ -759,6 +755,10 @@ static int dra7xx_pcie_probe(struct platform_device *pdev) return PTR_ERR(phy[i]); } + ret = clk_prepare_enable(dra7xx->clk); + if (ret) + return ret; + for (i = 0; i < phy_count; i++) { link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS); if (!link[i]) { -- 2.25.1