[PATCH 4/4] thermal/drivers/mediatek/lvts_thermal: skip sensors without a thermal zone in IRQ

From: Ilia Snezhkov via B4 Relay

Date: Wed Nov 25 2026 - 19:53:48 EST


From: Ilia Snezhkov <iasnezhkov@xxxxxxxxx>

lvts_ctrl_start() skips sensors absent from valid_sensor_mask as well as
sensors whose thermal zone is not present in the device tree (-ENODEV),
leaving lvts_ctrl->sensors[i].tz as NULL.

lvts_ctrl_irq_handler(), however, loops over all four sensor slots and
passes lvts_ctrl->sensors[i].tz unconditionally to
thermal_zone_device_update(), which dereferences tz immediately if a
status bit for an unpopulated sensor slot is set in LVTS_MONINTSTS.

Check lvts_ctrl->sensors[i].tz before calling
thermal_zone_device_update() while still acknowledging the status bit
with W1C.

Found and drafted with an AI coding assistant.

Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
Signed-off-by: Ilia Snezhkov <iasnezhkov@xxxxxxxxx>
---
drivers/thermal/mediatek/lvts_thermal.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index f0b7caa..5fc87a8 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -588,8 +588,9 @@ static irqreturn_t lvts_ctrl_irq_handler(struct lvts_ctrl *lvts_ctrl)
if (!(value & masks[i]))
continue;

- thermal_zone_device_update(lvts_ctrl->sensors[i].tz,
- THERMAL_TRIP_VIOLATED);
+ if (lvts_ctrl->sensors[i].tz)
+ thermal_zone_device_update(lvts_ctrl->sensors[i].tz,
+ THERMAL_TRIP_VIOLATED);
iret = IRQ_HANDLED;
}

--
2.54.0 (Apple Git-157)