linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mturquette@ti.com (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: allow clocks without parents to change rate
Date: Wed, 11 Jul 2012 16:42:29 -0700	[thread overview]
Message-ID: <20120711234229.GF2772@gmail.com> (raw)
In-Reply-To: <1341439772-649-1-git-send-email-linus.walleij@linaro.org>

On 20120705-00:09, Linus Walleij wrote:
> The clk_change_rate() code would dereference clk->parent
> to get clk->parent->rate without first checking that clk->parent
> was valid. This doesn't work if the clock is (A) a root clock
> and (B) can change rate. Such is the case with a VCO clock
> like the ICST which consequently crash like this without
> this patch:
> 
> Unable to handle kernel NULL pointer dereference at virtual address 0000001c
> pgd = c0004000
> [0000001c] *pgd=00000000
> Internal error: Oops: 5 [#1] PREEMPT ARM
> Modules linked in:
> CPU: 0    Not tainted  (3.5.0-rc3-00003-g8156866-dirty #193)
> PC is at clk_change_rate+0x34/0xd8
> LR is at clk_change_rate+0x18/0xd8
> 
> Cc: stable at kernel.org
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: Ulf Hansson <ulf.hansson@stericsson.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Hi Linus,

This has been fixed in Pawell's patch, "clk: Check parent for NULL in
clk_change_rate".

Thanks,
Mike

> ---
>  drivers/clk/clk.c |   22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 687b00d..032d79c 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -854,14 +854,22 @@ static void clk_change_rate(struct clk *clk)
>  
>  	old_rate = clk->rate;
>  
> -	if (clk->ops->set_rate)
> -		clk->ops->set_rate(clk->hw, clk->new_rate, clk->parent->rate);
> +	if (clk->ops->set_rate) {
> +		if (clk->parent)
> +			clk->ops->set_rate(clk->hw, clk->new_rate,
> +					clk->parent->rate);
> +		else
> +			clk->ops->set_rate(clk->hw, clk->new_rate, 0);
> +	}
>  
> -	if (clk->ops->recalc_rate)
> -		clk->rate = clk->ops->recalc_rate(clk->hw,
> -				clk->parent->rate);
> -	else
> -		clk->rate = clk->parent->rate;
> +	if (clk->ops->recalc_rate) {
> +		if (clk->parent)
> +			clk->rate = clk->ops->recalc_rate(clk->hw,
> +							clk->parent->rate);
> +		else
> +			clk->rate = clk->ops->recalc_rate(clk->hw, 0);
> +	} else
> +		clk->rate = clk->parent ? clk->parent->rate : 0;
>  
>  	if (clk->notifier_count && old_rate != clk->rate)
>  		__clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate);
> -- 
> 1.7.10.4
> 

  reply	other threads:[~2012-07-11 23:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04 22:09 [PATCH] clk: allow clocks without parents to change rate Linus Walleij
2012-07-11 23:42 ` Mike Turquette [this message]
2012-07-12 10:50   ` Linus Walleij
2012-07-12 16:54     ` Mike Turquette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120711234229.GF2772@gmail.com \
    --to=mturquette@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).