2018-04-19 13:09:52

by Potyra, Stefan

[permalink] [raw]
Subject: [PATCH] Check for an error when the clock is enabled.

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

Fixes: 0814e8d5da2b sc16is7xx: enable the clock
Signed-off-by: Stefan Potyra <[email protected]>
---
drivers/tty/serial/sc16is7xx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 65792a3539d0..243c96025053 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1168,7 +1168,10 @@ static int sc16is7xx_probe(struct device *dev,
else
return PTR_ERR(s->clk);
} else {
- clk_prepare_enable(s->clk);
+ ret = clk_prepare_enable(s->clk);
+ if (ret)
+ return ret;
+
freq = clk_get_rate(s->clk);
}

--
2.17.0



2018-04-23 07:58:31

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] Check for an error when the clock is enabled.

On Thu, Apr 19, 2018 at 03:02:28PM +0200, Stefan Potyra wrote:
> Found by Linux Driver Verification project (linuxtesting.org).

Please fix up your subject line to have something "real" in it, along
with the proper prefix.

And put more context here in the changelog, saying why you are doing
this, this "empty line" doesn't mean anything.

>
> Fixes: 0814e8d5da2b sc16is7xx: enable the clock

Fixes: 0814e8d5da2b ("sc16is7xx: enable the clock")

is the correct format.

> Signed-off-by: Stefan Potyra <[email protected]>
> ---
> drivers/tty/serial/sc16is7xx.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
> index 65792a3539d0..243c96025053 100644
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c
> @@ -1168,7 +1168,10 @@ static int sc16is7xx_probe(struct device *dev,
> else
> return PTR_ERR(s->clk);
> } else {
> - clk_prepare_enable(s->clk);
> + ret = clk_prepare_enable(s->clk);
> + if (ret)
> + return ret;
> +

Please fix up the above and resend.

thanks,

greg k-h

2018-04-24 16:20:35

by Potyra, Stefan

[permalink] [raw]
Subject: [PATCH v2] sc16is7xx: Check for an error when the clock is enabled.

When the clock is enabled, check if there is an error. Otherwise
clk_get_rate() can be called without enabled clock.

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

Fixes: 0814e8d5da2b ("sc16is7xx: enable the clock")
Signed-off-by: Stefan Potyra <[email protected]>
---
drivers/tty/serial/sc16is7xx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 65792a3539d0..243c96025053 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1168,7 +1168,10 @@ static int sc16is7xx_probe(struct device *dev,
else
return PTR_ERR(s->clk);
} else {
- clk_prepare_enable(s->clk);
+ ret = clk_prepare_enable(s->clk);
+ if (ret)
+ return ret;
+
freq = clk_get_rate(s->clk);
}

--
2.17.0