diff mbox

[LINUX-CCF] clk: must judge get_parent function return value in __clk_init.

Message ID 1382523448-29461-1-git-send-email-shaojie.sun@linaro.com
State New
Headers show

Commit Message

sunshaojie Oct. 23, 2013, 10:17 a.m. UTC
For get_parent function may be return a below zero value to
indicate that it could function a right value.
In this condition orphan->parent_names[i] will lead system a
access an unknown memory.

Signed-off-by: Shaojie Sun <shaojie.sun@linaro.com>
---
 drivers/clk/clk.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 1144e8c..fcb5c85 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1632,7 +1632,8 @@  int __clk_init(struct device *dev, struct clk *clk)
 	hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
 		if (orphan->ops->get_parent) {
 			i = orphan->ops->get_parent(orphan->hw);
-			if (!strcmp(clk->name, orphan->parent_names[i]))
+			if ((i >= 0)
+				&& !strcmp(clk->name, orphan->parent_names[i]))
 				__clk_reparent(orphan, clk);
 			continue;
 		}