Re: [PATCH] thermal/drivers/rcar: add error checking in probe()
From: Dan Carpenter
Date: Tue Jun 23 2026 - 04:25:48 EST
On Tue, Jun 23, 2026 at 10:18:22AM +0200, Niklas Söderlund wrote:
> Hi Dan,
>
> Thanks for your work.
>
> On 2026-06-23 10:49:29 +0300, Dan Carpenter wrote:
> > The thermal_zone_device_register_with_trips() can fail for a number of
> > reasons, including allocation failures. Check for error pointers to
> > avoid an error pointer dereference.
> >
> > Fixes: 9d617949d490 ("thermal/drivers/renesas: Group all renesas thermal drivers together")
>
> I don't think this is correct as this commits just moves the file.
>
> > Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
> > ---
> > drivers/thermal/renesas/rcar_thermal.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/thermal/renesas/rcar_thermal.c b/drivers/thermal/renesas/rcar_thermal.c
> > index 6e5dcac5d47a..71f836fbc698 100644
> > --- a/drivers/thermal/renesas/rcar_thermal.c
> > +++ b/drivers/thermal/renesas/rcar_thermal.c
> > @@ -492,6 +492,11 @@ static int rcar_thermal_probe(struct platform_device *pdev)
> > "rcar_thermal", trips, ARRAY_SIZE(trips), priv,
> > &rcar_thermal_zone_ops, NULL, 0,
> > idle);
> > + if (IS_ERR(priv->zone)) {
> > + ret = PTR_ERR(priv->zone);
> > + priv->zone = NULL;
> > + goto error_unregister;
> > + }
>
> While this indeed is an issue that should be fixed I don't think this is
> the correct fix. Below the if .. else .. block where this is added there
> already is a check for IS_ERR(priv->zone). That however does not guard
> against the usage of priv->zone for thermal_zone_device_enable().
>
> We should only call thermal_zone_device_enable() if we are on a system
> that uses OF (gated by chip->use_of_thermal) which is the reason for the
> if .. else .. block in the first place.
Uh, what? Other way around. Only when use_of_thermal is false.
This function is weirdly confusing... Also the rcar_thermal_remove()
function already calls thermal_zone_device_unregister(). I'll send a
v2 later.
regards,
dan carpenter