Patch "PCI: ftpci100: Release the clock resources" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    PCI: ftpci100: Release the clock resources

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pci-ftpci100-release-the-clock-resources.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d9c83ad50e70e515f58d592e5a298a460e44da62
Author: Junyan Ye <yejunyan@xxxxxxxxxxx>
Date:   Mon May 8 12:36:41 2023 +0800

    PCI: ftpci100: Release the clock resources
    
    [ Upstream commit c60738de85f40b0b9f5cb23c21f9246e5a47908c ]
    
    Smatch reported:
    1. drivers/pci/controller/pci-ftpci100.c:526 faraday_pci_probe() warn:
    'clk' from clk_prepare_enable() not released on lines: 442,451,462,478,512,517.
    2. drivers/pci/controller/pci-ftpci100.c:526 faraday_pci_probe() warn:
    'p->bus_clk' from clk_prepare_enable() not released on lines: 451,462,478,512,517.
    
    The clock resource is obtained by devm_clk_get(), and then
    clk_prepare_enable() makes the clock resource ready for use. After that,
    clk_disable_unprepare() should be called to release the clock resource
    when it is no longer needed. However, while doing some error handling
    in faraday_pci_probe(), clk_disable_unprepare() is not called to release
    clk and p->bus_clk before returning. These return lines are exactly 442,
    451, 462, 478, 512, 517.
    
    Fix this warning by replacing devm_clk_get() with devm_clk_get_enabled(),
    which is equivalent to devm_clk_get() + clk_prepare_enable(). And with
    devm_clk_get_enabled(), the clock will automatically be disabled,
    unprepared and freed when the device is unbound from the bus.
    
    Link: https://lore.kernel.org/r/20230508043641.23807-1-yejunyan@xxxxxxxxxxx
    Fixes: b3c433efb8a3 ("PCI: faraday: Fix wrong pointer passed to PTR_ERR()")
    Fixes: 2eeb02b28579 ("PCI: faraday: Add clock handling")
    Fixes: 783a862563f7 ("PCI: faraday: Use pci_parse_request_of_pci_ranges()")
    Fixes: d3c68e0a7e34 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI Host Bridge driver")
    Fixes: f1e8bd21e39e ("PCI: faraday: Convert IRQ masking to raw PCI config accessors")
    Signed-off-by: Junyan Ye <yejunyan@xxxxxxxxxxx>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@xxxxxxxxxx>
    Reviewed-by: Dongliang Mu <dzm91@xxxxxxxxxxx>
    Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c
index bf5ece5d9291f..88983fd0c1bdd 100644
--- a/drivers/pci/controller/pci-ftpci100.c
+++ b/drivers/pci/controller/pci-ftpci100.c
@@ -458,22 +458,12 @@ static int faraday_pci_probe(struct platform_device *pdev)
 	p->dev = dev;
 
 	/* Retrieve and enable optional clocks */
-	clk = devm_clk_get(dev, "PCLK");
+	clk = devm_clk_get_enabled(dev, "PCLK");
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
-	ret = clk_prepare_enable(clk);
-	if (ret) {
-		dev_err(dev, "could not prepare PCLK\n");
-		return ret;
-	}
-	p->bus_clk = devm_clk_get(dev, "PCICLK");
+	p->bus_clk = devm_clk_get_enabled(dev, "PCICLK");
 	if (IS_ERR(p->bus_clk))
 		return PTR_ERR(p->bus_clk);
-	ret = clk_prepare_enable(p->bus_clk);
-	if (ret) {
-		dev_err(dev, "could not prepare PCICLK\n");
-		return ret;
-	}
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	p->base = devm_ioremap_resource(dev, regs);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux