clk: make sure parent is not NULL in clk_fetch_parent_index()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 28 Dec 2015 10:23:08 +0000 (19:23 +0900)
committerStephen Boyd <sboyd@codeaurora.org>
Tue, 2 Feb 2016 19:53:15 +0000 (11:53 -0800)
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>
drivers/clk/clk.c

index 03820467fbba86bce711873f847268030cb93928..da7c9a523f02efd4d5dd26c5771ff178eab7969d 100644 (file)
@@ -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