Skip to contentSkip to conversation

m68k: let clk_enable() return immediately if clk is NULL

PATCH In review Defang Bo 2 participants 2 messages Dec 27, 2020

Subsystems (2)
lore
Share & tools
lore

Defang Bo

author
#0 lore raw

PATCH 2/2 m68k: let clk_enable() return immediately if clk is NULL

There should be a check for clk to prevent NULL pointer dereference.

---
 arch/m68k/coldfire/clk.c | 3 +++
 1 file changed, 3 insertions(+)
arch/m68k/coldfire/clk.c +3 -0
index 7bc666e..cf1ed97 100644
@@ -90,6 +90,9 @@ EXPORT_SYMBOL(clk_get);
 int clk_enable(struct clk *clk)
 {
 	unsigned long flags;
+	if (!clk)
+		return;
+
 	spin_lock_irqsave(&clk_lock, flags);
 	if ((clk->enabled++ == 0) && clk->clk_ops)
 		clk->clk_ops->enable(clk);
Signature · 1 line
2.7.4
#1 lore raw

arch/m68k/coldfire/clk.c EXPORT_SYMBOL(clk_get); · line 94

Quoted 10 lines · Defang Bo
arch/m68k/coldfire/clk.c +2 -0
index 7bc666e..cf1ed97 100644
@@ -90,6 +90,9 @@ EXPORT_SYMBOL(clk_get);
 int clk_enable(struct clk *clk)
 {
 	unsigned long flags;
+	if (!clk)
+		return;

That fails to return a value.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."