Skip to contentSkip to conversation

clk: ls1028a: fix a dereference of pointer 'parent' before a null check

PATCH Applied Colin King 2 participants 2 messages Feb 3, 2020 – Feb 4, 2020

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 clk: ls1028a: fix a dereference of pointer 'parent' before a null check

From: Colin Ian King <[email protected]>

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")
---
 drivers/clk/clk-plldig.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/clk-plldig.c +3 -1
index a5da08f98d01..f7c349d9c2dc 100644
@@ -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;
Signature · 1 line
2.24.0
maintainer Applied
#1 lore raw

Quoting Colin King (2020-02-03 14:37:36)

Quoted 10 lines

From: Colin Ian King <[email protected]>

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")

---

Applied to clk-next