Pawell,

Do you mind taking this one?

Thanks,
Mike

On Tue, Jul 10, 2012 at 5:23 PM,  <[email protected]> wrote:
>
> The patch below does not apply to the 3.4-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <[email protected]>.
>
> thanks,
>
> greg k-h
>
> ------------------ original commit in Linus's tree ------------------
>
> From bf47b4fd8f9f81cd5ce40e1945c6334d088226d1 Mon Sep 17 00:00:00 2001
> From: Pawel Moll <[email protected]>
> Date: Fri, 8 Jun 2012 14:04:06 +0100
> Subject: [PATCH] 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 <[email protected]>
> Signed-off-by: Mike Turquette <[email protected]>
> Cc: [email protected]
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index df89cbf..dcbe056 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);
>
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to