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 <mperttunen@nvidia.com> Acked-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 07101e1 commit 0eb82af

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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)