Browse Source

clk: make sure parent is not NULL in clk_fetch_parent_index()

If parent is given with NULL, clk_fetch_parent_index() could return
a positive index value.

Currently, parent is checked by the callers of this function, but
it would be safer to do it in this function.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Masahiro Yamada 9 years ago
parent
commit
508f884a66
1 changed files with 3 additions and 0 deletions
  1. 3 0
      drivers/clk/clk.c

+ 3 - 0
drivers/clk/clk.c

@@ -1066,6 +1066,9 @@ static int clk_fetch_parent_index(struct clk_core *core,
 {
 {
 	int i;
 	int i;
 
 
+	if (!parent)
+		return -EINVAL;
+
 	/*
 	/*
 	 * find index of new parent clock using cached parent ptrs,
 	 * find index of new parent clock using cached parent ptrs,
 	 * or if not yet cached, use string name comparison and cache
 	 * or if not yet cached, use string name comparison and cache