Skip to content

Commit 0eb82af

Browse files
cyndisgregkh
authored andcommitted
clk: tegra: bpmp: Don't crash when a clock fails to register
[ Upstream commit f7b3182 ] 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 <[email protected]> Acked-by: Jon Hunter <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 07101e1 commit 0eb82af

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/clk/tegra/clk-bpmp.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,15 @@ static struct clk_hw *tegra_bpmp_clk_of_xlate(struct of_phandle_args *clkspec,
581581
unsigned int id = clkspec->args[0], i;
582582
struct tegra_bpmp *bpmp = data;
583583

584-
for (i = 0; i < bpmp->num_clocks; i++)
585-
if (bpmp->clocks[i]->id == id)
586-
return &bpmp->clocks[i]->hw;
584+
for (i = 0; i < bpmp->num_clocks; i++) {
585+
struct tegra_bpmp_clk *clk = bpmp->clocks[i];
586+
587+
if (!clk)
588+
continue;
589+
590+
if (clk->id == id)
591+
return &clk->hw;
592+
}
587593

588594
return NULL;
589595
}

0 commit comments

Comments
 (0)