Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: tegra: Avoid calling an uninitialized function

Commit 493ffb046cf5 ("clk: tegra: super: Switch to determine_rate")
replaced clk_super_round_rate() by clk_super_determine_rate(), but
didn't update one callsite that was explicitly calling the old
tegra_clk_super_ops.round_rate() function, which was now NULL. This
resulted in a crash on Tegra30 systems during early boot.

Switch this callsite over to the clk_super_determine_rate() equivalent
to avoid the crash.

Fixes: 493ffb046cf5 ("clk: tegra: super: Switch to determine_rate")
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20230630130748.840729-1-thierry.reding@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Thierry Reding and committed by
Stephen Boyd
f679e89a b2115425

+12 -3
+12 -3
drivers/clk/tegra/clk-tegra-super-cclk.c
··· 86 86 if (rate <= pllp_rate) { 87 87 if (super->flags & TEGRA20_SUPER_CLK) 88 88 rate = pllp_rate; 89 - else 90 - rate = tegra_clk_super_ops.round_rate(hw, rate, 91 - &pllp_rate); 89 + else { 90 + struct clk_rate_request parent = { 91 + .rate = req->rate, 92 + .best_parent_rate = pllp_rate, 93 + }; 94 + 95 + clk_hw_get_rate_range(hw, &parent.min_rate, 96 + &parent.max_rate); 97 + tegra_clk_super_ops.determine_rate(hw, &parent); 98 + pllp_rate = parent.best_parent_rate; 99 + rate = parent.rate; 100 + } 92 101 93 102 req->best_parent_rate = pllp_rate; 94 103 req->best_parent_hw = pllp_hw;