public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: Mikko Perttunen <mperttunen@nvidia.com>,
	<pdeschrijver@nvidia.com>, <mturquette@baylibre.com>,
	<sboyd@kernel.org>, <thierry.reding@gmail.com>
Cc: <linux-clk@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <swarren@nvidia.com>,
	<vbhadram@nvidia.com>
Subject: Re: [PATCH] clk: tegra: bpmp: Don't crash when a clock fails to register
Date: Fri, 29 Jun 2018 15:41:45 +0100	[thread overview]
Message-ID: <f378f345-02db-f3fd-4c95-b1a2e8ecf3f5@nvidia.com> (raw)
In-Reply-To: <20180629143814.17950-1-mperttunen@nvidia.com>


On 29/06/18 15:38, Mikko Perttunen wrote:
> When registering clocks, we just skip any that fail to register
> (leaving a NULL hole in the clock table). However, our of_xlate
> function still tries to dereference each entry while looking for
> the clock with the requested id, causing a crash if any clocks
> failed to register. Add a check to of_xlate to skip any NULL
> clocks.
> 
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
>  drivers/clk/tegra/clk-bpmp.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c
> index a896692b74ec..01dada561c10 100644
> --- a/drivers/clk/tegra/clk-bpmp.c
> +++ b/drivers/clk/tegra/clk-bpmp.c
> @@ -586,9 +586,15 @@ static struct clk_hw *tegra_bpmp_clk_of_xlate(struct of_phandle_args *clkspec,
>  	unsigned int id = clkspec->args[0], i;
>  	struct tegra_bpmp *bpmp = data;
>  
> -	for (i = 0; i < bpmp->num_clocks; i++)
> -		if (bpmp->clocks[i]->id == id)
> -			return &bpmp->clocks[i]->hw;
> +	for (i = 0; i < bpmp->num_clocks; i++) {
> +		struct tegra_bpmp_clk *clk = bpmp->clocks[i];
> +
> +		if (!clk)
> +			continue;
> +
> +		if (clk->id == id)
> +			return &clk->hw;
> +	}
>  
>  	return NULL;
>  }

Acked-by: Jon Hunter <jonathanh@nvidia.com>

Cheers!
Jon

-- 
nvpublic

  reply	other threads:[~2018-06-29 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29 14:38 [PATCH] clk: tegra: bpmp: Don't crash when a clock fails to register Mikko Perttunen
2018-06-29 14:41 ` Jon Hunter [this message]
2018-07-08 23:56 ` Stephen Boyd

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=f378f345-02db-f3fd-4c95-b1a2e8ecf3f5@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=mturquette@baylibre.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=sboyd@kernel.org \
    --cc=swarren@nvidia.com \
    --cc=thierry.reding@gmail.com \
    --cc=vbhadram@nvidia.com \
    /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