From: Ilia Snezhkov via B4 Relay <devnull+iasnezhkov.gmail.com@kernel.org>
To: daniel.lezcano@linaro.org, rafael@kernel.org,
rui.zhang@intel.com, lukasz.luba@arm.com
Cc: matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
linux-pm@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] thermal/drivers/mediatek/lvts_thermal: skip sensors without a thermal zone in IRQ
Date: Thu, 26 Nov 2026 00:53:25 +0000 [thread overview]
Message-ID: <20261126005321.71799-5-iasnezhkov@gmail.com> (raw)
In-Reply-To: <20261126005321.71799-1-iasnezhkov@gmail.com>
From: Ilia Snezhkov <iasnezhkov@gmail.com>
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@gmail.com>
---
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)
prev parent reply other threads:[~2026-11-26 0:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 0:53 [PATCH 0/4] thermal/drivers/mediatek/lvts_thermal: CALSCALE, overflow, locking, and IRQ NULL fixes Ilia Snezhkov via B4 Relay
2026-11-26 0:53 ` [PATCH 1/4] thermal/drivers/mediatek/lvts_thermal: write LVTS_CALSCALE in lvts_ctrl_configure() Ilia Snezhkov via B4 Relay
2026-11-26 0:53 ` [PATCH 2/4] thermal/drivers/mediatek/lvts_thermal: avoid 32-bit overflow in lvts_temp_to_raw_mt7988() and INT_MAX trips Ilia Snezhkov via B4 Relay
2026-11-26 0:53 ` [PATCH 3/4] thermal/drivers/mediatek/lvts_thermal: serialize lvts_set_trips() per controller Ilia Snezhkov via B4 Relay
2026-11-26 0:53 ` Ilia Snezhkov via B4 Relay [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126005321.71799-5-iasnezhkov@gmail.com \
--to=devnull+iasnezhkov.gmail.com@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=daniel.lezcano@linaro.org \
--cc=iasnezhkov@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox