* [U-Boot] [PATCH] clk: sandbox: don't check clk ID against 0
@ 2016-06-21 19:32 Stephen Warren
2016-06-22 14:52 ` Simon Glass
2016-06-25 2:53 ` [U-Boot] " Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Warren @ 2016-06-21 19:32 UTC (permalink / raw)
To: u-boot
From: Stephen Warren <swarren@nvidia.com>
clk->id is unsigned, so it can't be < 0. Remove the check for that.
FWIW, this issue was introduced when the clock API converted e.g.
clk_get_rate()'s clock ID parameter from an int to an unsigned long
(with a struct clk), without removing this check.
Fixes: 135aa9500264 ("clk: convert API to match reset/mailbox style")
Reported-by: Coverity Scan
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
drivers/clk/clk_sandbox.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index c6bd7c64e291..ef585037fcd4 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -19,7 +19,7 @@ static ulong sandbox_clk_get_rate(struct clk *clk)
{
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
- if (clk->id < 0 || clk->id >= SANDBOX_CLK_ID_COUNT)
+ if (clk->id >= SANDBOX_CLK_ID_COUNT)
return -EINVAL;
return priv->rate[clk->id];
@@ -30,7 +30,7 @@ static ulong sandbox_clk_set_rate(struct clk *clk, ulong rate)
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
ulong old_rate;
- if (clk->id < 0 || clk->id >= SANDBOX_CLK_ID_COUNT)
+ if (clk->id >= SANDBOX_CLK_ID_COUNT)
return -EINVAL;
if (!rate)
@@ -46,7 +46,7 @@ static int sandbox_clk_enable(struct clk *clk)
{
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
- if (clk->id < 0 || clk->id >= SANDBOX_CLK_ID_COUNT)
+ if (clk->id >= SANDBOX_CLK_ID_COUNT)
return -EINVAL;
priv->enabled[clk->id] = true;
@@ -58,7 +58,7 @@ static int sandbox_clk_disable(struct clk *clk)
{
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
- if (clk->id < 0 || clk->id >= SANDBOX_CLK_ID_COUNT)
+ if (clk->id >= SANDBOX_CLK_ID_COUNT)
return -EINVAL;
priv->enabled[clk->id] = false;
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] clk: sandbox: don't check clk ID against 0
2016-06-21 19:32 [U-Boot] [PATCH] clk: sandbox: don't check clk ID against 0 Stephen Warren
@ 2016-06-22 14:52 ` Simon Glass
2016-06-25 2:53 ` [U-Boot] " Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2016-06-22 14:52 UTC (permalink / raw)
To: u-boot
On 21 June 2016 at 13:32, Stephen Warren <swarren@wwwdotorg.org> wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> clk->id is unsigned, so it can't be < 0. Remove the check for that.
>
> FWIW, this issue was introduced when the clock API converted e.g.
> clk_get_rate()'s clock ID parameter from an int to an unsigned long
> (with a struct clk), without removing this check.
>
> Fixes: 135aa9500264 ("clk: convert API to match reset/mailbox style")
> Reported-by: Coverity Scan
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> drivers/clk/clk_sandbox.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] clk: sandbox: don't check clk ID against 0
2016-06-21 19:32 [U-Boot] [PATCH] clk: sandbox: don't check clk ID against 0 Stephen Warren
2016-06-22 14:52 ` Simon Glass
@ 2016-06-25 2:53 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2016-06-25 2:53 UTC (permalink / raw)
To: u-boot
On Tue, Jun 21, 2016 at 01:32:07PM -0600, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> clk->id is unsigned, so it can't be < 0. Remove the check for that.
>
> FWIW, this issue was introduced when the clock API converted e.g.
> clk_get_rate()'s clock ID parameter from an int to an unsigned long
> (with a struct clk), without removing this check.
>
> Fixes: 135aa9500264 ("clk: convert API to match reset/mailbox style")
> Reported-by: Coverity Scan
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160624/6413ea42/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-25 2:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-21 19:32 [U-Boot] [PATCH] clk: sandbox: don't check clk ID against 0 Stephen Warren
2016-06-22 14:52 ` Simon Glass
2016-06-25 2:53 ` [U-Boot] " Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox