diff options
author | Pawel Moll <pawel.moll@arm.com> | 2012-06-08 09:04:06 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2012-06-25 19:51:48 -0400 |
commit | bf47b4fd8f9f81cd5ce40e1945c6334d088226d1 (patch) | |
tree | 2bec386cffb13652e45cd9e4bca533744a492209 /drivers/clk | |
parent | 7975059db572eb47f0fb272a62afeae272a4b209 (diff) |
clk: Check parent for NULL in clk_change_rate
clk_change_rate() is accessing parent's rate without checking
if the parent exists at all. In case of root clocks this will
cause NULL pointer dereference.
This patch follows what clk_calc_new_rates() does in such
situation.
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Cc: stable@kernel.org
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index df89cbfc1bd0..dcbe05616090 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -850,18 +850,21 @@ static void clk_change_rate(struct clk *clk) | |||
850 | { | 850 | { |
851 | struct clk *child; | 851 | struct clk *child; |
852 | unsigned long old_rate; | 852 | unsigned long old_rate; |
853 | unsigned long best_parent_rate = 0; | ||
853 | struct hlist_node *tmp; | 854 | struct hlist_node *tmp; |
854 | 855 | ||
855 | old_rate = clk->rate; | 856 | old_rate = clk->rate; |
856 | 857 | ||
858 | if (clk->parent) | ||
859 | best_parent_rate = clk->parent->rate; | ||
860 | |||
857 | if (clk->ops->set_rate) | 861 | if (clk->ops->set_rate) |
858 | clk->ops->set_rate(clk->hw, clk->new_rate, clk->parent->rate); | 862 | clk->ops->set_rate(clk->hw, clk->new_rate, best_parent_rate); |
859 | 863 | ||
860 | if (clk->ops->recalc_rate) | 864 | if (clk->ops->recalc_rate) |
861 | clk->rate = clk->ops->recalc_rate(clk->hw, | 865 | clk->rate = clk->ops->recalc_rate(clk->hw, best_parent_rate); |
862 | clk->parent->rate); | ||
863 | else | 866 | else |
864 | clk->rate = clk->parent->rate; | 867 | clk->rate = best_parent_rate; |
865 | 868 | ||
866 | if (clk->notifier_count && old_rate != clk->rate) | 869 | if (clk->notifier_count && old_rate != clk->rate) |
867 | __clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate); | 870 | __clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate); |