soc/tegra: pmc: Guard against uninitialised PMC clock
authorJon Hunter <jonathanh@nvidia.com>
Sat, 22 Oct 2016 19:23:52 +0000 (20:23 +0100)
committerThierry Reding <treding@nvidia.com>
Tue, 15 Nov 2016 14:51:52 +0000 (15:51 +0100)
commitf4392d6da5f52727a53298321f4dfeac6df1a093
treeabdb54e436b6687280574d9b9cfebb5130cfc39e
parent21b4991051780b49b217c363f79366ed94c3b4b7
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: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/soc/tegra/pmc.c