Skip to content

Commit

Permalink
clk: tegra: bpmp: Don't crash when a clock fails to register
Browse files Browse the repository at this point in the history
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>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Mikko Perttunen authored and Stephen Boyd committed Jul 8, 2018
1 parent ce397d2 commit f7b3182
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/clk/tegra/clk-bpmp.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit f7b3182

Please sign in to comment.