MLK-17641 thermal: imx: Fix race condition in imx_thermal_probe()
authorAnson Huang <Anson.Huang@nxp.com>
Thu, 1 Mar 2018 08:45:28 +0000 (16:45 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Tue, 20 Mar 2018 19:55:58 +0000 (14:55 -0500)
commitcf1ab6b9ea6a18fcd8a6fec6ab0fcff1a99b2809
treee127045203d731f0f617ff7ba6b3378c2eb78388
parentc713ccdb2e0d0101a5bdb7f650123da2ef264b25
MLK-17641 thermal: imx: Fix race condition in imx_thermal_probe()

Upstream reports below race condition:

When device boots with T > T_trip_1 and requests interrupt,
the race condition takes place. The interrupt comes before
THERMAL_DEVICE_ENABLED is set. This leads to an attempt to
reading sensor value from irq and disabling the sensor,
based on the data->mode field, which expected to be
THERMAL_DEVICE_ENABLED, but still stays as THERMAL_DEVICE_DISABLED.
Afher this issue sensor is never re-enabled, as the driver state is wrong.

Fix this problem by setting the 'data' members prior to requesting
the interrupts.

Signed-off-by: Mikhail Lappo <mikhail.lappo@esrlabs.com>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Bai Ping <ping.bai@nxp.com>
drivers/thermal/imx_thermal.c