linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] clk: ls1028a: fix a dereference of pointer 'parent' before a null check
@ 2020-02-03 22:37 Colin King
  2020-02-04  7:03 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-02-03 22:37 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Wen He, Michael Walle, linux-clk
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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>
---
 drivers/clk/clk-plldig.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-plldig.c b/drivers/clk/clk-plldig.c
index a5da08f98d01..f7c349d9c2dc 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;
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] clk: ls1028a: fix a dereference of pointer 'parent' before a null check
  2020-02-03 22:37 [PATCH][next] clk: ls1028a: fix a dereference of pointer 'parent' before a null check Colin King
@ 2020-02-04  7:03 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2020-02-04  7:03 UTC (permalink / raw)
  To: Colin King, Michael Turquette, Michael Walle, Wen He, linux-clk
  Cc: kernel-janitors, linux-kernel

Quoting Colin King (2020-02-03 14:37:36)
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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>
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-04  7:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 22:37 [PATCH][next] clk: ls1028a: fix a dereference of pointer 'parent' before a null check Colin King
2020-02-04  7:03 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).