[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lsq.1539530740.493199865@decadent.org.uk>
Date: Sun, 14 Oct 2018 16:25:40 +0100
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org, "Fabio Estevam" <fabio.estevam@....com>,
"Mikhail Lappo" <mikhail.lappo@...labs.com>,
"Dong Aisheng" <aisheng.dong@....com>,
"Zhang Rui" <rui.zhang@...el.com>,
"Philipp Zabel" <p.zabel@...gutronix.de>
Subject: [PATCH 3.16 037/366] thermal: imx: Fix race condition in
imx_thermal_probe()
3.16.60-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Lappo <mikhail.lappo@...labs.com>
commit cf1ba1d73a33944d8c1a75370a35434bf146b8a7 upstream.
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.
Fixes: 37713a1e8e4c ("thermal: imx: implement thermal alarm interrupt handling")
Signed-off-by: Mikhail Lappo <mikhail.lappo@...labs.com>
Signed-off-by: Fabio Estevam <fabio.estevam@....com>
Reviewed-by: Philipp Zabel <p.zabel@...gutronix.de>
Acked-by: Dong Aisheng <aisheng.dong@....com>
Signed-off-by: Zhang Rui <rui.zhang@...el.com>
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
drivers/thermal/imx_thermal.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -484,6 +484,9 @@ static int imx_thermal_probe(struct plat
regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);
+ data->irq_enabled = true;
+ data->mode = THERMAL_DEVICE_ENABLED;
+
ret = devm_request_threaded_irq(&pdev->dev, data->irq,
imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread,
0, "imx_thermal", data);
@@ -495,9 +498,6 @@ static int imx_thermal_probe(struct plat
return ret;
}
- data->irq_enabled = true;
- data->mode = THERMAL_DEVICE_ENABLED;
-
return 0;
}
Powered by blists - more mailing lists