2017-12-01 20:26:37

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH] fpga: socfpga-a10: disable clk on error in socfpga_a10_fpga_probe()

If fpga_mgr_register() fails, a clock is left undisabled.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <[email protected]>
---
drivers/fpga/socfpga-a10.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/fpga/socfpga-a10.c b/drivers/fpga/socfpga-a10.c
index f8770af0f6b5..a46e343a5b72 100644
--- a/drivers/fpga/socfpga-a10.c
+++ b/drivers/fpga/socfpga-a10.c
@@ -519,8 +519,14 @@ static int socfpga_a10_fpga_probe(struct platform_device *pdev)
return -EBUSY;
}

- return fpga_mgr_register(dev, "SoCFPGA Arria10 FPGA Manager",
+ ret = fpga_mgr_register(dev, "SoCFPGA Arria10 FPGA Manager",
&socfpga_a10_fpga_mgr_ops, priv);
+ if (ret) {
+ clk_disable_unprepare(priv->clk);
+ return ret;
+ }
+
+ return 0;
}

static int socfpga_a10_fpga_remove(struct platform_device *pdev)
--
2.7.4


2017-12-02 01:21:13

by Moritz Fischer

[permalink] [raw]
Subject: Re: [PATCH] fpga: socfpga-a10: disable clk on error in socfpga_a10_fpga_probe()

Hi Alexey,

On Fri, Dec 01, 2017 at 11:26:24PM +0300, Alexey Khoroshilov wrote:
> If fpga_mgr_register() fails, a clock is left undisabled.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
Reviewed-by: Moritz Fischer <[email protected]>
> ---
> drivers/fpga/socfpga-a10.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/fpga/socfpga-a10.c b/drivers/fpga/socfpga-a10.c
> index f8770af0f6b5..a46e343a5b72 100644
> --- a/drivers/fpga/socfpga-a10.c
> +++ b/drivers/fpga/socfpga-a10.c
> @@ -519,8 +519,14 @@ static int socfpga_a10_fpga_probe(struct platform_device *pdev)
> return -EBUSY;
> }
>
> - return fpga_mgr_register(dev, "SoCFPGA Arria10 FPGA Manager",
> + ret = fpga_mgr_register(dev, "SoCFPGA Arria10 FPGA Manager",
> &socfpga_a10_fpga_mgr_ops, priv);
> + if (ret) {
> + clk_disable_unprepare(priv->clk);
> + return ret;
> + }
> +
> + return 0;
> }
>
> static int socfpga_a10_fpga_remove(struct platform_device *pdev)
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

Thanks for your patch,

Moritz

2017-12-04 15:45:35

by Alan Tull

[permalink] [raw]
Subject: Re: [PATCH] fpga: socfpga-a10: disable clk on error in socfpga_a10_fpga_probe()

On Fri, Dec 1, 2017 at 7:21 PM, Moritz Fischer <[email protected]> wrote:

Hi Alexey,

Thanks for the fix!

Alan

> Hi Alexey,
>
> On Fri, Dec 01, 2017 at 11:26:24PM +0300, Alexey Khoroshilov wrote:
>> If fpga_mgr_register() fails, a clock is left undisabled.
>>
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov <[email protected]>
> Reviewed-by: Moritz Fischer <[email protected]>

Acked-by: Alan Tull <[email protected]>

>> ---
>> drivers/fpga/socfpga-a10.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/fpga/socfpga-a10.c b/drivers/fpga/socfpga-a10.c
>> index f8770af0f6b5..a46e343a5b72 100644
>> --- a/drivers/fpga/socfpga-a10.c
>> +++ b/drivers/fpga/socfpga-a10.c
>> @@ -519,8 +519,14 @@ static int socfpga_a10_fpga_probe(struct platform_device *pdev)
>> return -EBUSY;
>> }
>>
>> - return fpga_mgr_register(dev, "SoCFPGA Arria10 FPGA Manager",
>> + ret = fpga_mgr_register(dev, "SoCFPGA Arria10 FPGA Manager",
>> &socfpga_a10_fpga_mgr_ops, priv);
>> + if (ret) {
>> + clk_disable_unprepare(priv->clk);
>> + return ret;
>> + }
>> +
>> + return 0;
>> }
>>
>> static int socfpga_a10_fpga_remove(struct platform_device *pdev)
>> --
>> 2.7.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> Thanks for your patch,
>
> Moritz