* [PATCH] m68k: let clk_enable() return immediately if clk is NULL
@ 2020-12-28 2:07 Defang Bo
2020-12-28 7:48 ` Geert Uytterhoeven
2021-01-25 13:24 ` Greg Ungerer
0 siblings, 2 replies; 3+ messages in thread
From: Defang Bo @ 2020-12-28 2:07 UTC (permalink / raw)
To: gerg, geert; +Cc: linux-m68k, linux-kernel, Defang Bo
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>
---
arch/m68k/coldfire/clk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c
index 7bc666e..6decd11 100644
--- a/arch/m68k/coldfire/clk.c
+++ b/arch/m68k/coldfire/clk.c
@@ -90,6 +90,9 @@ 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);
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] m68k: let clk_enable() return immediately if clk is NULL
2020-12-28 2:07 [PATCH] m68k: let clk_enable() return immediately if clk is NULL Defang Bo
@ 2020-12-28 7:48 ` Geert Uytterhoeven
2021-01-25 13:24 ` Greg Ungerer
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-12-28 7:48 UTC (permalink / raw)
To: Defang Bo; +Cc: Greg Ungerer, linux-m68k, Linux Kernel Mailing List
Hi Defang,
On Mon, Dec 28, 2020 at 3:08 AM Defang Bo <bodefang@126.com> wrote:
> 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>
Thanks for your patch!
> --- a/arch/m68k/coldfire/clk.c
> +++ b/arch/m68k/coldfire/clk.c
> @@ -90,6 +90,9 @@ EXPORT_SYMBOL(clk_get);
> int clk_enable(struct clk *clk)
> {
> unsigned long flags;
Please keep the blank line between variable declarations and
statements (no complaint from scripts/checkpatch.pl? See
Documentation/process/submitting-patches.rst
).
> + if (!clk)
> + return -EINVAL;
> +
> spin_lock_irqsave(&clk_lock, flags);
> if ((clk->enabled++ == 0) && clk->clk_ops)
> clk->clk_ops->enable(clk);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] m68k: let clk_enable() return immediately if clk is NULL
2020-12-28 2:07 [PATCH] m68k: let clk_enable() return immediately if clk is NULL Defang Bo
2020-12-28 7:48 ` Geert Uytterhoeven
@ 2021-01-25 13:24 ` Greg Ungerer
1 sibling, 0 replies; 3+ messages in thread
From: Greg Ungerer @ 2021-01-25 13:24 UTC (permalink / raw)
To: Defang Bo, geert; +Cc: linux-m68k, linux-kernel
Hi Defang,
On 28/12/20 12:07 pm, Defang Bo wrote:
> 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>
I have applied this to the m68knommu git tree, for-next branch -
with blank line added as per Geert's suggestion.
Regards
Greg
> ---
> arch/m68k/coldfire/clk.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c
> index 7bc666e..6decd11 100644
> --- a/arch/m68k/coldfire/clk.c
> +++ b/arch/m68k/coldfire/clk.c
> @@ -90,6 +90,9 @@ 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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-26 6:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 2:07 [PATCH] m68k: let clk_enable() return immediately if clk is NULL Defang Bo
2020-12-28 7:48 ` Geert Uytterhoeven
2021-01-25 13:24 ` Greg Ungerer
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).