* [PATCH v3] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe
@ 2020-11-06 3:12 Qinglang Miao
2020-11-06 3:42 ` [PATCH v4] " Qinglang Miao
0 siblings, 1 reply; 3+ messages in thread
From: Qinglang Miao @ 2020-11-06 3:12 UTC (permalink / raw)
To: Linus Walleij, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, Qinglang Miao
From: miaoqinglang 00503101 <miaoqinglang@huawei.com>
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@kernel.org>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
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.
drivers/pci/controller/pci-v3-semi.c | 49 +++++++++++++++++-----------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c
index 154a53986..f862a56a3 100644
--- a/drivers/pci/controller/pci-v3-semi.c
+++ b/drivers/pci/controller/pci-v3-semi.c
@@ -725,18 +725,6 @@ static int v3_pci_probe(struct platform_device *pdev)
host->sysdata = v3;
v3->dev = dev;
- /* Get and enable host clock */
- clk = devm_clk_get(dev, NULL);
- if (IS_ERR(clk)) {
- dev_err(dev, "clock not found\n");
- return PTR_ERR(clk);
- }
- ret = clk_prepare_enable(clk);
- if (ret) {
- dev_err(dev, "unable to enable clock\n");
- return ret;
- }
-
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
v3->base = devm_ioremap_resource(dev, regs);
if (IS_ERR(v3->base))
@@ -761,10 +749,24 @@ static int v3_pci_probe(struct platform_device *pdev)
if (IS_ERR(v3->config_base))
return PTR_ERR(v3->config_base);
+ /* Get and enable host clock */
+ clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(clk)) {
+ dev_err(dev, "clock not found\n");
+ return PTR_ERR(clk);
+ }
+ ret = clk_prepare_enable(clk);
+ if (ret) {
+ dev_err(dev, "unable to enable clock\n");
+ return ret;
+ }
+
/* Get and request error IRQ resource */
irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ if (irq < 0) {
+ ret = irq;
+ goto err_clk;
+ }
ret = devm_request_irq(dev, irq, v3_irq, 0,
"PCIv3 error", v3);
@@ -772,7 +774,7 @@ static int v3_pci_probe(struct platform_device *pdev)
dev_err(dev,
"unable to request PCIv3 error IRQ %d (%d)\n",
irq, ret);
- return ret;
+ goto err_clk;
}
/*
@@ -814,12 +816,12 @@ static int v3_pci_probe(struct platform_device *pdev)
ret = v3_pci_setup_resource(v3, host, win);
if (ret) {
dev_err(dev, "error setting up resources\n");
- return ret;
+ goto err_clk;
}
}
ret = v3_pci_parse_map_dma_ranges(v3, np);
if (ret)
- return ret;
+ goto err_clk;
/*
* Disable PCI to host IO cycles, enable I/O buffers @3.3V,
@@ -863,7 +865,7 @@ static int v3_pci_probe(struct platform_device *pdev)
if (of_device_is_compatible(np, "arm,integrator-ap-pci")) {
ret = v3_integrator_init(v3);
if (ret)
- return ret;
+ goto err_clk;
}
/* Post-init: enable PCI memory and invalidate (master already on) */
@@ -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;
+
+err_clk:
+ clk_disable_unprepare(clk);
+
+ return ret;
}
static const struct of_device_id v3_pci_of_match[] = {
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v4] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe
2020-11-06 3:12 [PATCH v3] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe Qinglang Miao
@ 2020-11-06 3:42 ` Qinglang Miao
2020-11-06 22:40 ` Rob Herring
0 siblings, 1 reply; 3+ messages in thread
From: Qinglang Miao @ 2020-11-06 3:42 UTC (permalink / raw)
To: Linus Walleij, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, Qinglang Miao
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@kernel.org>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
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(-)
diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c
index 154a53986..f862a56a3 100644
--- a/drivers/pci/controller/pci-v3-semi.c
+++ b/drivers/pci/controller/pci-v3-semi.c
@@ -725,18 +725,6 @@ static int v3_pci_probe(struct platform_device *pdev)
host->sysdata = v3;
v3->dev = dev;
- /* Get and enable host clock */
- clk = devm_clk_get(dev, NULL);
- if (IS_ERR(clk)) {
- dev_err(dev, "clock not found\n");
- return PTR_ERR(clk);
- }
- ret = clk_prepare_enable(clk);
- if (ret) {
- dev_err(dev, "unable to enable clock\n");
- return ret;
- }
-
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
v3->base = devm_ioremap_resource(dev, regs);
if (IS_ERR(v3->base))
@@ -761,10 +749,24 @@ static int v3_pci_probe(struct platform_device *pdev)
if (IS_ERR(v3->config_base))
return PTR_ERR(v3->config_base);
+ /* Get and enable host clock */
+ clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(clk)) {
+ dev_err(dev, "clock not found\n");
+ return PTR_ERR(clk);
+ }
+ ret = clk_prepare_enable(clk);
+ if (ret) {
+ dev_err(dev, "unable to enable clock\n");
+ return ret;
+ }
+
/* Get and request error IRQ resource */
irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ if (irq < 0) {
+ ret = irq;
+ goto err_clk;
+ }
ret = devm_request_irq(dev, irq, v3_irq, 0,
"PCIv3 error", v3);
@@ -772,7 +774,7 @@ static int v3_pci_probe(struct platform_device *pdev)
dev_err(dev,
"unable to request PCIv3 error IRQ %d (%d)\n",
irq, ret);
- return ret;
+ goto err_clk;
}
/*
@@ -814,12 +816,12 @@ static int v3_pci_probe(struct platform_device *pdev)
ret = v3_pci_setup_resource(v3, host, win);
if (ret) {
dev_err(dev, "error setting up resources\n");
- return ret;
+ goto err_clk;
}
}
ret = v3_pci_parse_map_dma_ranges(v3, np);
if (ret)
- return ret;
+ goto err_clk;
/*
* Disable PCI to host IO cycles, enable I/O buffers @3.3V,
@@ -863,7 +865,7 @@ static int v3_pci_probe(struct platform_device *pdev)
if (of_device_is_compatible(np, "arm,integrator-ap-pci")) {
ret = v3_integrator_init(v3);
if (ret)
- return ret;
+ goto err_clk;
}
/* Post-init: enable PCI memory and invalidate (master already on) */
@@ -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;
+
+err_clk:
+ clk_disable_unprepare(clk);
+
+ return ret;
}
static const struct of_device_id v3_pci_of_match[] = {
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe
2020-11-06 3:42 ` [PATCH v4] " Qinglang Miao
@ 2020-11-06 22:40 ` Rob Herring
0 siblings, 0 replies; 3+ messages in thread
From: Rob Herring @ 2020-11-06 22:40 UTC (permalink / raw)
To: Qinglang Miao
Cc: Linus Walleij, Lorenzo Pieralisi, Bjorn Helgaas, PCI, linux-kernel
On Thu, Nov 5, 2020 at 9:37 PM Qinglang Miao <miaoqinglang@huawei.com> 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@kernel.org>
> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
> ---
> 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@kernel.org>
> +
> +err_clk:
> + clk_disable_unprepare(clk);
> +
> + return ret;
> }
>
> static const struct of_device_id v3_pci_of_match[] = {
> --
> 2.23.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-06 22:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 3:12 [PATCH v3] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe Qinglang Miao
2020-11-06 3:42 ` [PATCH v4] " Qinglang Miao
2020-11-06 22:40 ` Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).