clk: only call get_parent if there is one
authorAlex Elder <alex.elder@linaro.org>
Thu, 5 Sep 2013 13:33:24 +0000 (08:33 -0500)
committer黄涛 <huangtao@rock-chips.com>
Wed, 8 Jan 2014 03:05:24 +0000 (11:05 +0800)
commitf3620ba73f0b38d587b4a7dbe7b11e350eebdada
tree12ee62fbb928988bb8f1eccd1dbf774eca29077b
parent05ce4e7d0bff01176a33f3a71cbb8cd6cb5465f4
clk: only call get_parent if there is one

In __clk_init(), after a clock is mostly initialized, a scan is done
of the orphan clocks to see if the clock being registered is the
parent of any of them.

This code assumes that any clock that provides a get_parent method
actually has at least one parent, and that's not a valid assumption.

As a result, an orphan clock with no parent can return *something*
as the parent index, and that value is blindly used to dereference
the orphan's parent_names[] array (which will be ZERO_SIZE_PTR or
NULL).

Fix this by ensuring get_parent is only called for orphans with at
least one parent.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/clk.c