summaryrefslogtreecommitdiff
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorPawel Moll <pawel.moll@arm.com>2012-06-08 17:04:06 +0400
committerMike Turquette <mturquette@linaro.org>2012-06-26 03:51:48 +0400
commitbf47b4fd8f9f81cd5ce40e1945c6334d088226d1 (patch)
tree2bec386cffb13652e45cd9e4bca533744a492209 /drivers/clk/clk.c
parent7975059db572eb47f0fb272a62afeae272a4b209 (diff)
downloadlinux-bf47b4fd8f9f81cd5ce40e1945c6334d088226d1.tar.xz
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/clk.c')
-rw-r--r--drivers/clk/clk.c11
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)
{
struct clk *child;
unsigned long old_rate;
+ unsigned long best_parent_rate = 0;
struct hlist_node *tmp;
old_rate = clk->rate;
+ if (clk->parent)
+ best_parent_rate = clk->parent->rate;
+
if (clk->ops->set_rate)
- clk->ops->set_rate(clk->hw, clk->new_rate, clk->parent->rate);
+ clk->ops->set_rate(clk->hw, clk->new_rate, best_parent_rate);
if (clk->ops->recalc_rate)
- clk->rate = clk->ops->recalc_rate(clk->hw,
- clk->parent->rate);
+ clk->rate = clk->ops->recalc_rate(clk->hw, best_parent_rate);
else
- clk->rate = clk->parent->rate;
+ clk->rate = best_parent_rate;
if (clk->notifier_count && old_rate != clk->rate)
__clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate);