aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@linaro.org>2013-10-20 15:42:02 +0800
committerZhangfei Gao <zhangfei.gao@linaro.org>2013-11-11 16:48:20 +0800
commit77480a23418fb9c0b9b562da7fbff852b30be2b2 (patch)
treee6165cf1fc3964e86b84c743c03cc4e8423a5c73
parentb2381f2b7cc1245e870c20b4212804ba84b55bcb (diff)
clk: mux: fix the return value of get_parent
If there're no parents on the clock mux node, it should return 0, not an errnor code. The orphan clock node is using get_parent() to get the index of its parents in__clk_init(). If the return value is negative, it'll be transformed to a u8 value (clk_mux_get_parent()). Then the orphan clock node tries to get its parent with the invalid index. It will only cause accessing memory beyond border. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
-rw-r--r--drivers/clk/clk-mux.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 4f96ff3ba728..cc06015aee0a 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;
}