mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it
@ 2026-02-04 13:34 Claudiu
  2026-02-10 12:54 ` Claudiu Beznea
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Claudiu @ 2026-02-04 13:34 UTC (permalink / raw)
  To: p.zabel, biju.das.jz; +Cc: claudiu.beznea, linux-kernel, Claudiu Beznea

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

The pwrrdy regmap_filed is allocated in rzg2l_usbphy_ctrl_pwrrdy_init()
only if the driver data is set to RZG2L_USBPHY_CTRL_PWRRDY. Check that
pwrrdy is valid before using it to avoid "Unable to handle kernel NULL
pointer dereference at virtual address" errors.

Fixes: c5b7cd9adefc ("reset: rzg2l-usbphy-ctrl: Add suspend/resume support")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
 drivers/reset/reset-rzg2l-usbphy-ctrl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
index 32bc268c9149..05dd9b4a02df 100644
--- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
+++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
@@ -136,6 +136,9 @@ static int rzg2l_usbphy_ctrl_set_pwrrdy(struct regmap_field *pwrrdy,
 {
 	u32 val = power_on ? 0 : 1;
 
+	if (!pwrrdy)
+		return 0;
+
 	/* The initialization path guarantees that the mask is 1 bit long. */
 	return regmap_field_update_bits(pwrrdy, 1, val);
 }
-- 
2.43.0


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

* Re: [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it
  2026-02-04 13:34 [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it Claudiu
@ 2026-02-10 12:54 ` Claudiu Beznea
  2026-02-18  9:04 ` Biju Das
  2026-02-23 16:06 ` Philipp Zabel
  2 siblings, 0 replies; 4+ messages in thread
From: Claudiu Beznea @ 2026-02-10 12:54 UTC (permalink / raw)
  To: p.zabel, biju.das.jz; +Cc: linux-kernel, Claudiu Beznea

Hi, Philipp,

On 2/4/26 15:34, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> The pwrrdy regmap_filed is allocated in rzg2l_usbphy_ctrl_pwrrdy_init()
> only if the driver data is set to RZG2L_USBPHY_CTRL_PWRRDY. Check that
> pwrrdy is valid before using it to avoid "Unable to handle kernel NULL
> pointer dereference at virtual address" errors.
> 
> Fixes: c5b7cd9adefc ("reset: rzg2l-usbphy-ctrl: Add suspend/resume support")
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

If all good for you in with this patch, could you please take it along with the 
suspend/resume support on this driver to avoid any regression?

Thank you,
Claudiu

> ---
>   drivers/reset/reset-rzg2l-usbphy-ctrl.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> index 32bc268c9149..05dd9b4a02df 100644
> --- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> +++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> @@ -136,6 +136,9 @@ static int rzg2l_usbphy_ctrl_set_pwrrdy(struct regmap_field *pwrrdy,
>   {
>   	u32 val = power_on ? 0 : 1;
>   
> +	if (!pwrrdy)
> +		return 0;
> +
>   	/* The initialization path guarantees that the mask is 1 bit long. */
>   	return regmap_field_update_bits(pwrrdy, 1, val);
>   }


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

* RE: [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it
  2026-02-04 13:34 [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it Claudiu
  2026-02-10 12:54 ` Claudiu Beznea
@ 2026-02-18  9:04 ` Biju Das
  2026-02-23 16:06 ` Philipp Zabel
  2 siblings, 0 replies; 4+ messages in thread
From: Biju Das @ 2026-02-18  9:04 UTC (permalink / raw)
  To: Claudiu.Beznea, p.zabel
  Cc: Claudiu.Beznea, linux-kernel, Claudiu Beznea,
	open list:PIN CONTROLLER - RENESAS

Hi Claudiu,

Thanks for the patch.

> -----Original Message-----
> From: Claudiu <claudiu.beznea@tuxon.dev>
> Sent: 04 February 2026 13:34
> Subject: [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it
> 
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> The pwrrdy regmap_filed is allocated in rzg2l_usbphy_ctrl_pwrrdy_init() only if the driver data is set
> to RZG2L_USBPHY_CTRL_PWRRDY. Check that pwrrdy is valid before using it to avoid "Unable to handle
> kernel NULL pointer dereference at virtual address" errors.
> 
> Fixes: c5b7cd9adefc ("reset: rzg2l-usbphy-ctrl: Add suspend/resume support")

Thanks for fixing it, as it leads to crash on non-RZ/G3S platforms.

Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

Cheers,
Biju

> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
>  drivers/reset/reset-rzg2l-usbphy-ctrl.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> index 32bc268c9149..05dd9b4a02df 100644
> --- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> +++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> @@ -136,6 +136,9 @@ static int rzg2l_usbphy_ctrl_set_pwrrdy(struct regmap_field *pwrrdy,  {
>  	u32 val = power_on ? 0 : 1;
> 
> +	if (!pwrrdy)
> +		return 0;
> +
>  	/* The initialization path guarantees that the mask is 1 bit long. */
>  	return regmap_field_update_bits(pwrrdy, 1, val);  }
> --
> 2.43.0


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

* Re: [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it
  2026-02-04 13:34 [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it Claudiu
  2026-02-10 12:54 ` Claudiu Beznea
  2026-02-18  9:04 ` Biju Das
@ 2026-02-23 16:06 ` Philipp Zabel
  2 siblings, 0 replies; 4+ messages in thread
From: Philipp Zabel @ 2026-02-23 16:06 UTC (permalink / raw)
  To: Claudiu, biju.das.jz; +Cc: linux-kernel, Claudiu Beznea

On Mi, 2026-02-04 at 15:34 +0200, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> The pwrrdy regmap_filed is allocated in rzg2l_usbphy_ctrl_pwrrdy_init()
> only if the driver data is set to RZG2L_USBPHY_CTRL_PWRRDY. Check that
> pwrrdy is valid before using it to avoid "Unable to handle kernel NULL
> pointer dereference at virtual address" errors.
> 
> Fixes: c5b7cd9adefc ("reset: rzg2l-usbphy-ctrl: Add suspend/resume support")
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
>  drivers/reset/reset-rzg2l-usbphy-ctrl.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> index 32bc268c9149..05dd9b4a02df 100644
> --- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> +++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> @@ -136,6 +136,9 @@ static int rzg2l_usbphy_ctrl_set_pwrrdy(struct regmap_field *pwrrdy,
>  {
>  	u32 val = power_on ? 0 : 1;
>  
> +	if (!pwrrdy)
> +		return 0;
> +
>  	/* The initialization path guarantees that the mask is 1 bit long. */
>  	return regmap_field_update_bits(pwrrdy, 1, val);
>  }

Applied to reset/fixes, thanks!

[1/1] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it
      https://git.pengutronix.de/cgit/pza/linux/commit/?id=e0cf84109bc6

regards
Philipp

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

end of thread, other threads:[~2026-02-23 16:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-04 13:34 [PATCH] reset: rzg2l-usbphy-ctrl: Check pwrrdy is valid before using it Claudiu
2026-02-10 12:54 ` Claudiu Beznea
2026-02-18  9:04 ` Biju Das
2026-02-23 16:06 ` Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®