summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2015-12-28 11:23:08 +0100
committerStephen Boyd <sboyd@codeaurora.org>2016-02-02 20:53:15 +0100
commit508f884a66abb61f22fcc2b36ab1e68492f1d295 (patch)
tree3f29be1edc1ea605eed5430a717b3ae5020f79b9 /drivers/clk/clk.c
parentclk: walk the orphan clock list more simply (diff)
downloadlinux-508f884a66abb61f22fcc2b36ab1e68492f1d295.tar.xz
linux-508f884a66abb61f22fcc2b36ab1e68492f1d295.zip
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>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c3
1 files changed, 3 insertions, 0 deletions
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