Skip to content

Commit

Permalink
clk: make sure parent is not NULL in clk_fetch_parent_index()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Masahiro Yamada authored and Stephen Boyd committed Feb 2, 2016
1 parent 0e8f6e4 commit 508f884
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 508f884

Please sign in to comment.