Re: [PATCH 2/2] drivers/thermal/rcar_gen3_thermal: Fix device initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Wolfram,

Thanks for your review.

On 2023-02-08 08:58:33 +0100, Wolfram Sang wrote:
> On Tue, Feb 07, 2023 at 06:10:11PM +0100, Niklas Söderlund wrote:
> > The thermal zone is registered before the device is register and the
> > thermal coefficients are calculated, providing a window for very
> > incorrect readings.
> 
> While I could never actually be in this race window, the patch makes a
> lot of sense to me.
> 
> > The reason why the zone was register before the device was fully
> > initialized was that the presence of the set_trips() callback is used to
> > determine if the driver supports interrupt or not, as it is not defined
> > if the device is incapable of interrupts.
> > 
> > Fix this by using the operations structure in the private data instead
> > of the zone to determine if interrupts are available or not, and
> > initialize the device before registering the zone.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
> 
> Reviewed-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
> 
> One minor question:
> 
> > -		if (status)
> > +		if (status && priv->tscs[i]->zone)
> >  			thermal_zone_device_update(priv->tscs[i]->zone,
> >  						   THERMAL_EVENT_UNSPECIFIED);
> 
> Isn't this a seperate change?

Not really.

This patch changes the driver to enable interrupts just before the zone 
is created. So this just guards from the very small window where an 
interrupt could be fired and the zone is created, which if it would 
happen would cause a null pointer dereference.

While not updating a not yet created zone is fine. But this should never 
happen (tm) as the trip points have not been set when this window 
exists, but better safe then sorry.

-- 
Kind Regards,
Niklas Söderlund



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux