Re: [PATCH v2] pci: controller: pci-ftpci100: Release the clock resources

From: Bjorn Helgaas
Date: Thu Apr 27 2023 - 14:38:40 EST


On Sun, Apr 23, 2023 at 01:32:07PM +0800, Junyan Ye 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.

If/when you repost this, please:

- Rebase to v6.4-rc1 (when it's available).

- Look at subject line history for this file and match it.

- Include the smatch warnings exactly above (not wrapped to fit in
75 columns). This is to make it easier to search for the text.

- Add "()" after function names below to make it obvious they are
functions. You can also omit "function", e.g., "... is obtained
by devm_clk_get()."

> 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.

I don't know the clk terminology. Does "... clock resource should be
run" mean the clock should be "running" or "enabled"?
include/linux/clk.h only uses "running" twice but has many instances
of "enable", so maybe that would be better. Or maybe it's enough to
say:

clk_prepare_enable() then makes the clock resource ready for use.

and omit the rest of that sentence?

Looks like a nice fix, thank you!

Bjorn