lkml.org 
[lkml]   [2013]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] clk: mux: Return a sane value on error
Date
The get_parent op is defined as returning u8, but clk-mux is
returning negative values on error. Code within drivers/clk/clk.c
uses this return value as an index into an array which could
cause an oops.

Signed-off-by: Russ Dill <Russ.Dill@ti.com>
---
drivers/clk/clk-mux.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 4f96ff3..cc06015 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -51,7 +51,7 @@ static u8 clk_mux_get_parent(struct clk_hw *hw)
for (i = 0; i < num_parents; i++)
if (mux->table[i] == val)
return i;
- return -EINVAL;
+ return 0;
}

if (val && (mux->flags & CLK_MUX_INDEX_BIT))
@@ -61,7 +61,7 @@ static u8 clk_mux_get_parent(struct clk_hw *hw)
val--;

if (val >= num_parents)
- return -EINVAL;
+ return 0;

return val;
}
--
1.8.3.2


\
 
 \ /
  Last update: 2013-10-21 11:21    [W:0.042 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site