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: <CACRpkdbDfAJOWzkvEgOdoOCMQAQ24mauWAeWXWgvBmyU3mi0FQ@mail.gmail.com>
Date:   Wed, 26 Apr 2023 22:44:28 +0200
From:   Linus Walleij <linus.walleij@...aro.org>
To:     Junyan Ye <yejunyan@...t.edu.cn>
Cc:     christophe.jaillet@...adoo.fr,
        Lorenzo Pieralisi <lpieralisi@...nel.org>,
        Krzysztof Wilczyński <kw@...ux.com>,
        Rob Herring <robh@...nel.org>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Wei Yongjun <weiyongjun1@...wei.com>,
        Andrew Murray <amurray@...goodpenguin.co.uk>,
        hust-os-kernel-patches@...glegroups.com,
        Dongliang Mu <dzm91@...t.edu.cn>, linux-pci@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] pci: controller: pci-ftpci100: Release the clock resources

On Sun, Apr 23, 2023 at 7:34 AM Junyan Ye <yejunyan@...t.edu.cn> wrote:

> 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 the devm_clk_get function. The
> clk_prepare_enable function then makes the clock resource ready for use,
> notifying the system that the clock resource should be run. After that,
> the clock resource should be released when it is no longer needed. The
> corresponding function is clk_disable_unprepare. However, while doing
> some error handling in the faraday_pci_probe function, the
> clk_disable_unprepare function is not called to release the clk and
> p->bus_clk resources.
>
> Fix this warning by changing the devm_clk_get function to
> devm_clk_get_enabled, which is equivalent to
> devm_clk_get() + clk_prepare_enable(). And with the
> devm_clk_get_enabled function, the clock will automatically be
> disabled, unprepared and freed when the device is unbound from the bus.
>
> 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@...t.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@...t.edu.cn>
> ---
> v1 -> v2: Switch from clk_disable_unprepare() to devm_clk_get_enabled() to release the clock.
> This issue is found by static analyzer.

Neat fix, saves codelines!
Reviewed-by: Linus Walleij <linus.walleij@...aro.org>

Yours,
Linus Walleij

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ