From patchwork Tue Dec 14 22:14:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 12696122 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B8E4C433F5 for ; Tue, 14 Dec 2021 22:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u3EE+AuCCvjtpkNJav9RyPQupsPaMugD3GgFQHu4x4k=; b=Jp7OrlNv2wtuC8 yGLXLuTv4mBiQ8NDMQGjxebiHtAld5YCSXKI62qIjPrdO0jDfWROSNNErcqjUk0LC4d/BUFwLvgxt ukQbIloORaBd1pRXkfFk/WsgZ4gLXDYXSUEGWivGxE6AdA9WV6We50GBtkxcPilB4TgCmMSj6gOIO vOXvhPLQ6lorn+SUd8VuTJRvVp4IJORSOOzaWhFo9ifdzTyUk1KhpDnFtPDIvCEoHntONAxlCritC ld3Bm0yDdAhfouLZZYFS8o3Rccf4q1qZYcjdh4lErKnREIGWrWcr8thgxXLIvziZ9uhIBqw8Ko7yI ODUpJ5lERgkWAIKBfZDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxG54-00FuhK-H2; Tue, 14 Dec 2021 22:15:30 +0000 Received: from hostingweb31-40.netsons.net ([89.40.174.40]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxG4s-00FudB-0u for linux-arm-kernel@lists.infradead.org; Tue, 14 Dec 2021 22:15:19 +0000 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_Wilczy=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 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 - lists.infradead.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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211214_141518_268100_FC21DCBF X-CRM114-Status: UNSURE ( 9.33 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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]) {