lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211214221450.589884-2-luca@lucaceresoli.net>
Date:   Tue, 14 Dec 2021 23:14:50 +0100
From:   Luca Ceresoli <luca@...aceresoli.net>
To:     linux-pci@...r.kernel.org
Cc:     Luca Ceresoli <luca@...aceresoli.net>,
        Dan Carpenter <dan.carpenter@...cle.com>,
        linux-omap@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org,
        Kishon Vijay Abraham I <kishon@...com>,
        Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Rob Herring <robh@...nel.org>,
        Krzysztof WilczyƄski <kw@...ux.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Sekhar Nori <nsekhar@...com>, kernel test robot <lkp@...el.com>
Subject: [PATCH 2/2] PCI: dra7xx: Fix clk disabling in some error paths

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 <dan.carpenter@...cle.com>
Reported-by: kernel test robot <lkp@...el.com>
Link: https://lore.kernel.org/lkml/202111301803.NOwoj4Jd-lkp@intel.com/
Signed-off-by: Luca Ceresoli <luca@...aceresoli.net>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ