summaryrefslogtreecommitdiff
path: root/drivers/clk/clk-plldig.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2020-02-03 22:37:36 +0000
committerStephen Boyd <sboyd@kernel.org>2020-02-03 23:03:49 -0800
commit73cb3106e883ac03cc4f15b20d525e6bde650526 (patch)
tree4a96b6b4ff47a6e694ef03d58b9494b1a7ca3d04 /drivers/clk/clk-plldig.c
parent2a8aa18c113124434a32c1bd01054d67f799e4ee (diff)
downloadlwn-73cb3106e883ac03cc4f15b20d525e6bde650526.tar.gz
lwn-73cb3106e883ac03cc4f15b20d525e6bde650526.zip
clk: ls1028a: fix a dereference of pointer 'parent' before a null check
Currently the pointer 'parent' is being dereferenced before it is being null checked. Fix this by performing the null check before it is dereferenced. Addresses-Coverity: ("Dereference before null check") Fixes: d37010a3c162 ("clk: ls1028a: Add clock driver for Display output interface") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lkml.kernel.org/r/20200203223736.99645-1-colin.king@canonical.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/clk-plldig.c')
-rw-r--r--drivers/clk/clk-plldig.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/clk/clk-plldig.c b/drivers/clk/clk-plldig.c
index 312b8312d503..25020164b89e 100644
--- a/drivers/clk/clk-plldig.c
+++ b/drivers/clk/clk-plldig.c
@@ -187,7 +187,7 @@ static int plldig_init(struct clk_hw *hw)
{
struct clk_plldig *data = to_clk_plldig(hw);
struct clk_hw *parent = clk_hw_get_parent(hw);
- unsigned long parent_rate = clk_hw_get_rate(parent);
+ unsigned long parent_rate;
unsigned long val;
unsigned long long lltmp;
unsigned int mfd, fracdiv = 0;
@@ -195,6 +195,8 @@ static int plldig_init(struct clk_hw *hw)
if (!parent)
return -EINVAL;
+ parent_rate = clk_hw_get_rate(parent);
+
if (data->vco_freq) {
mfd = data->vco_freq / parent_rate;
lltmp = data->vco_freq % parent_rate;