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

Similar to commit<742859adc721>("m68k: let clk_disable() return immediately if clk is NULL").
there should be a check for clk to prevent NULL pointer dereference.

Signed-off-by: Defang Bo <bodefang@126.com>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
This commit is contained in:
Defang Bo 2020-12-28 10:07:45 +08:00 committed by Greg Ungerer
parent 92bf22614b
commit c1fb1bf64b

View file

@ -90,6 +90,10 @@ EXPORT_SYMBOL(clk_get);
int clk_enable(struct clk *clk)
{
unsigned long flags;
if (!clk)
return -EINVAL;
spin_lock_irqsave(&clk_lock, flags);
if ((clk->enabled++ == 0) && clk->clk_ops)
clk->clk_ops->enable(clk);