From: Masahiro Yamada Date: Mon, 28 Dec 2015 10:23:08 +0000 (+0900) Subject: clk: make sure parent is not NULL in clk_fetch_parent_index() X-Git-Tag: v4.6-rc1~44^2~101 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=508f884a66abb61f22fcc2b36ab1e68492f1d295;p=linux.git 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 Reviewed-by: Vladimir Zapolskiy Signed-off-by: Stephen Boyd --- diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 03820467fbba..da7c9a523f02 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1066,6 +1066,9 @@ static int clk_fetch_parent_index(struct clk_core *core, { int i; + if (!parent) + return -EINVAL; + /* * find index of new parent clock using cached parent ptrs, * or if not yet cached, use string name comparison and cache