* [PATCH] watchdog: asm9260_wdt: fix error handling in asm9260_wdt_probe()
@ 2018-02-09 21:56 Alexey Khoroshilov
2018-02-09 22:32 ` Guenter Roeck
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Khoroshilov @ 2018-02-09 21:56 UTC (permalink / raw)
To: Wim Van Sebroeck, Guenter Roeck
Cc: Alexey Khoroshilov, linux-watchdog, linux-kernel, ldv-project
If devm_reset_control_get_exclusive() fails, asm9260_wdt_probe()
returns immediately. But clks has been already enabled at that point,
so it is required to disable them.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/watchdog/asm9260_wdt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
index 7dd0da644a7f..de9e538a5fa8 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -297,8 +297,10 @@ static int asm9260_wdt_probe(struct platform_device *pdev)
return ret;
priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst");
- if (IS_ERR(priv->rst))
- return PTR_ERR(priv->rst);
+ if (IS_ERR(priv->rst)) {
+ ret = PTR_ERR(priv->rst);
+ goto clk_off;
+ }
wdd = &priv->wdd;
wdd->info = &asm9260_wdt_ident;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] watchdog: asm9260_wdt: fix error handling in asm9260_wdt_probe()
2018-02-09 21:56 [PATCH] watchdog: asm9260_wdt: fix error handling in asm9260_wdt_probe() Alexey Khoroshilov
@ 2018-02-09 22:32 ` Guenter Roeck
2018-02-10 10:17 ` [PATCH v2] " Alexey Khoroshilov
0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2018-02-09 22:32 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel, ldv-project
On Sat, Feb 10, 2018 at 12:56:29AM +0300, Alexey Khoroshilov wrote:
> If devm_reset_control_get_exclusive() fails, asm9260_wdt_probe()
> returns immediately. But clks has been already enabled at that point,
> so it is required to disable them.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/watchdog/asm9260_wdt.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
> index 7dd0da644a7f..de9e538a5fa8 100644
> --- a/drivers/watchdog/asm9260_wdt.c
> +++ b/drivers/watchdog/asm9260_wdt.c
> @@ -297,8 +297,10 @@ static int asm9260_wdt_probe(struct platform_device *pdev)
> return ret;
>
> priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst");
> - if (IS_ERR(priv->rst))
> - return PTR_ERR(priv->rst);
> + if (IS_ERR(priv->rst)) {
> + ret = PTR_ERR(priv->rst);
> + goto clk_off;
> + }
Good catch.
I would prefer to move the code around, ie call
devm_reset_control_get_exclusive() first and get the clocks
later.
Thanks,
Guenter
>
> wdd = &priv->wdd;
> wdd->info = &asm9260_wdt_ident;
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] watchdog: asm9260_wdt: fix error handling in asm9260_wdt_probe()
2018-02-09 22:32 ` Guenter Roeck
@ 2018-02-10 10:17 ` Alexey Khoroshilov
2018-02-11 17:46 ` [v2] " Guenter Roeck
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Khoroshilov @ 2018-02-10 10:17 UTC (permalink / raw)
To: Guenter Roeck, Wim Van Sebroeck
Cc: Alexey Khoroshilov, linux-watchdog, linux-kernel, ldv-project
If devm_reset_control_get_exclusive() fails, asm9260_wdt_probe()
returns immediately. But clks has been already enabled at that point,
so it is required to disable them or to move the code around.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
v2: Move the code around instead of disabling clks as Guenter Roeck suggested.
drivers/watchdog/asm9260_wdt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
index 7dd0da644a7f..2cf56b459d84 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -292,14 +292,14 @@ static int asm9260_wdt_probe(struct platform_device *pdev)
if (IS_ERR(priv->iobase))
return PTR_ERR(priv->iobase);
- ret = asm9260_wdt_get_dt_clks(priv);
- if (ret)
- return ret;
-
priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst");
if (IS_ERR(priv->rst))
return PTR_ERR(priv->rst);
+ ret = asm9260_wdt_get_dt_clks(priv);
+ if (ret)
+ return ret;
+
wdd = &priv->wdd;
wdd->info = &asm9260_wdt_ident;
wdd->ops = &asm9260_wdt_ops;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [v2] watchdog: asm9260_wdt: fix error handling in asm9260_wdt_probe()
2018-02-10 10:17 ` [PATCH v2] " Alexey Khoroshilov
@ 2018-02-11 17:46 ` Guenter Roeck
0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2018-02-11 17:46 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel, ldv-project
On Sat, Feb 10, 2018 at 01:17:27PM +0300, Alexey Khoroshilov wrote:
> If devm_reset_control_get_exclusive() fails, asm9260_wdt_probe()
> returns immediately. But clks has been already enabled at that point,
> so it is required to disable them or to move the code around.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v2: Move the code around instead of disabling clks as Guenter Roeck suggested.
>
> drivers/watchdog/asm9260_wdt.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
> index 7dd0da644a7f..2cf56b459d84 100644
> --- a/drivers/watchdog/asm9260_wdt.c
> +++ b/drivers/watchdog/asm9260_wdt.c
> @@ -292,14 +292,14 @@ static int asm9260_wdt_probe(struct platform_device *pdev)
> if (IS_ERR(priv->iobase))
> return PTR_ERR(priv->iobase);
>
> - ret = asm9260_wdt_get_dt_clks(priv);
> - if (ret)
> - return ret;
> -
> priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst");
> if (IS_ERR(priv->rst))
> return PTR_ERR(priv->rst);
>
> + ret = asm9260_wdt_get_dt_clks(priv);
> + if (ret)
> + return ret;
> +
> wdd = &priv->wdd;
> wdd->info = &asm9260_wdt_ident;
> wdd->ops = &asm9260_wdt_ops;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-11 17:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-09 21:56 [PATCH] watchdog: asm9260_wdt: fix error handling in asm9260_wdt_probe() Alexey Khoroshilov
2018-02-09 22:32 ` Guenter Roeck
2018-02-10 10:17 ` [PATCH v2] " Alexey Khoroshilov
2018-02-11 17:46 ` [v2] " Guenter Roeck
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).