diff mbox series

clk: renesas: rcar-usb2-clock-sel: Fix kernel NULL pointer dereference

Message ID 20210826141721.495067-1-aford173@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series clk: renesas: rcar-usb2-clock-sel: Fix kernel NULL pointer dereference | expand

Commit Message

Adam Ford Aug. 26, 2021, 2:17 p.m. UTC
The probe was manually passing NULL instead of dev to devm_clk_hw_register.
This caused a Unable to handle kernel NULL pointer dereference error.
Fix this by passing 'dev'.

Signed-off-by: Adam Ford <aford173@gmail.com>

Comments

Geert Uytterhoeven Aug. 26, 2021, 5:42 p.m. UTC | #1
On Thu, Aug 26, 2021 at 4:17 PM Adam Ford <aford173@gmail.com> wrote:
> The probe was manually passing NULL instead of dev to devm_clk_hw_register.
> This caused a Unable to handle kernel NULL pointer dereference error.
> Fix this by passing 'dev'.
>
> Signed-off-by: Adam Ford <aford173@gmail.com>

Fixes: a20a40a8bbc2cf4b ("clk: renesas: rcar-usb2-clock-sel: Fix error
handling in .probe()")
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Mike/Stephen: Can you please take this one directly, as we're
already at rc7.
Thanks!

> --- a/drivers/clk/renesas/rcar-usb2-clock-sel.c
> +++ b/drivers/clk/renesas/rcar-usb2-clock-sel.c
> @@ -187,7 +187,7 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
>         init.ops = &usb2_clock_sel_clock_ops;
>         priv->hw.init = &init;
>
> -       ret = devm_clk_hw_register(NULL, &priv->hw);
> +       ret = devm_clk_hw_register(dev, &priv->hw);
>         if (ret)
>                 goto pm_put;
>
> --
> 2.25.1

Gr{oetje,eeting}s,

                        Geert
Stephen Boyd Aug. 29, 2021, 4:28 a.m. UTC | #2
Quoting Geert Uytterhoeven (2021-08-26 10:42:29)
> On Thu, Aug 26, 2021 at 4:17 PM Adam Ford <aford173@gmail.com> wrote:
> > The probe was manually passing NULL instead of dev to devm_clk_hw_register.
> > This caused a Unable to handle kernel NULL pointer dereference error.
> > Fix this by passing 'dev'.
> >
> > Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> Fixes: a20a40a8bbc2cf4b ("clk: renesas: rcar-usb2-clock-sel: Fix error
> handling in .probe()")
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Mike/Stephen: Can you please take this one directly, as we're
> already at rc7.
> Thanks!
> 

It looks highly unlikely to make the cut but I'll try to send it off to
Linus tomorrow.
Stephen Boyd Aug. 29, 2021, 4:29 a.m. UTC | #3
Quoting Adam Ford (2021-08-26 07:17:21)
> The probe was manually passing NULL instead of dev to devm_clk_hw_register.
> This caused a Unable to handle kernel NULL pointer dereference error.
> Fix this by passing 'dev'.
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/drivers/clk/renesas/rcar-usb2-clock-sel.c b/drivers/clk/renesas/rcar-usb2-clock-sel.c
> index 9fb79bd79435..684d8937965e 100644
> --- a/drivers/clk/renesas/rcar-usb2-clock-sel.c

Applied to clk-fixes
diff mbox series

Patch

diff --git a/drivers/clk/renesas/rcar-usb2-clock-sel.c b/drivers/clk/renesas/rcar-usb2-clock-sel.c
index 9fb79bd79435..684d8937965e 100644
--- a/drivers/clk/renesas/rcar-usb2-clock-sel.c
+++ b/drivers/clk/renesas/rcar-usb2-clock-sel.c
@@ -187,7 +187,7 @@  static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
 	init.ops = &usb2_clock_sel_clock_ops;
 	priv->hw.init = &init;
 
-	ret = devm_clk_hw_register(NULL, &priv->hw);
+	ret = devm_clk_hw_register(dev, &priv->hw);
 	if (ret)
 		goto pm_put;