]> git.baikalelectronics.ru Git - kernel.git/commit
clk: check for invalid parent index of orphans in __clk_init()
authorMans Rullgard <mans@mansr.com>
Sun, 15 Feb 2015 12:33:49 +0000 (12:33 +0000)
committerStephen Boyd <sboyd@codeaurora.org>
Wed, 16 Sep 2015 22:35:18 +0000 (15:35 -0700)
commitd5e9dd30164c254c09ee2c2ada010da55b9e5f65
treef04390e54f455155eea0975be5cf9e9ef23552b8
parent83d2a7fae32af204a09606ff19ddde056cab6a6e
clk: check for invalid parent index of orphans in __clk_init()

If a mux clock is initialised (by hardware or firmware) with an
invalid parent, its ->get_parent() can return an out of range
index.  For example, the generic mux clock attempts to return
-EINVAL, which due to the u8 return type ends up a rather large
number.  Using this index with the parent_names[] array results
in an invalid pointer and (usually) a crash in the following
strcmp().

This patch adds a check for the parent index being in range,
ignoring clocks reporting invalid values.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Tested-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/clk.c