Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4392d6d authored by Jon Hunter's avatar Jon Hunter Committed by Thierry Reding
Browse files

soc/tegra: pmc: Guard against uninitialised PMC clock



It is possible for the public functions, tegra_io_rail_power_on/off()
to be called before the PMC device has been probed. If this happens
then the pmc->clk member will not be initialised and the call to
clk_get_rate() in tegra_io_rail_prepare() will return zero and lead
to a divide-by-zero exception. The function clk_get_rate() will return
zero if a NULl clk pointer is passed. Therefore, rather that checking
if pmc->clk is initialised, fix this by checking the return value for
clk_get_rate() to make sure it is not zero.

Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent 21b49910
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -957,6 +957,8 @@ static int tegra_io_pad_prepare(enum tegra_io_pad id, unsigned long *request,
	}

	rate = clk_get_rate(pmc->clk);
	if (!rate)
		return -ENODEV;

	tegra_pmc_writel(DPD_SAMPLE_ENABLE, DPD_SAMPLE);