aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Hunter <jonathanh@nvidia.com>2016-10-22 15:23:52 -0400
committerThierry Reding <treding@nvidia.com>2016-11-15 09:51:52 -0500
commitf4392d6da5f52727a53298321f4dfeac6df1a093 (patch)
treeabdb54e436b6687280574d9b9cfebb5130cfc39e
parent21b4991051780b49b217c363f79366ed94c3b4b7 (diff)
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>
-rw-r--r--drivers/soc/tegra/pmc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 81968ef19618..c8b54b9dc093 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -957,6 +957,8 @@ static int tegra_io_pad_prepare(enum tegra_io_pad id, unsigned long *request,
957 } 957 }
958 958
959 rate = clk_get_rate(pmc->clk); 959 rate = clk_get_rate(pmc->clk);
960 if (!rate)
961 return -ENODEV;
960 962
961 tegra_pmc_writel(DPD_SAMPLE_ENABLE, DPD_SAMPLE); 963 tegra_pmc_writel(DPD_SAMPLE_ENABLE, DPD_SAMPLE);
962 964