Re: [PATCH v4] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe

From: Rob Herring
Date: Fri Nov 06 2020 - 17:42:56 EST


On Thu, Nov 5, 2020 at 9:37 PM Qinglang Miao <miaoqinglang@xxxxxxxxxx> wrote:
>
> Fix the missing clk_disable_unprepare() before return
> from v3_pci_probe() in the error handling case.
>
> I also move the clock-enable function later to avoid some
> fixes.
>
> Fixes: 68a15eb7bd0c ("PCI: v3-semi: Add V3 Semiconductor PCI host driver")
> Suggested-by: Rob Herring <robh@xxxxxxxxxx>
> Signed-off-by: Qinglang Miao <miaoqinglang@xxxxxxxxxx>
> ---
> v2: add commit causing this problem and add more error handling
> cases which are not enough.
> v3: 1. fix the wrong 'Fixes commit'.
> 2. use goto to clean up this patch.
> 3. cover all error handling cases.
> v4: fix uncorresponding author name.
> drivers/pci/controller/pci-v3-semi.c | 49 +++++++++++++++++-----------
> 1 file changed, 30 insertions(+), 19 deletions(-)

[...]

> @@ -889,7 +891,16 @@ static int v3_pci_probe(struct platform_device *pdev)
> val |= V3_SYSTEM_M_LOCK;
> writew(val, v3->base + V3_SYSTEM);
>
> - return pci_host_probe(host);
> + ret = pci_host_probe(host);
> + if (ret < 0)
> + goto err_clk;
> +
> + return 0;

Slightly simpler to do:

ret = pci_host_probe(host);
if (!ret)
return 0;

err_clk:


With that,

Reviewed-by: Rob Herring <robh@xxxxxxxxxx>

> +
> +err_clk:
> + clk_disable_unprepare(clk);
> +
> + return ret;
> }
>
> static const struct of_device_id v3_pci_of_match[] = {
> --
> 2.23.0
>