mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:09:29 +02:00
thermal/drivers/spacemit: Validate clamped trip thresholds
k1_tsensor_set_trips() checks the requested trip temperatures before
converting them to the sensor register representation. Distinct
out-of-range temperatures can clamp to the same hardware value, leaving the
sensor with an invalid low/high threshold pair.
Validate the ordering after conversion and clamping.
Fixes: 296a977f2b ("thermal/drivers/spacemit/k1: Add thermal sensor support")
Signed-off-by: surendra <kr494167@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Link: https://patch.msgid.link/20260720103606.93924-1-kr494167@gmail.com
This commit is contained in:
@@ -156,13 +156,12 @@ static int k1_tsensor_set_trips(struct thermal_zone_device *tz, int low, int hig
|
||||
struct k1_tsensor *ts = ch->ts;
|
||||
u32 val;
|
||||
|
||||
if (low >= high)
|
||||
return -EINVAL;
|
||||
|
||||
low = clamp_val(low / 1000 + TEMPERATURE_OFFSET, TEMPERATURE_OFFSET,
|
||||
FIELD_MAX(K1_TSENSOR_THRSH_LOW_MASK));
|
||||
high = clamp_val(high / 1000 + TEMPERATURE_OFFSET, TEMPERATURE_OFFSET,
|
||||
FIELD_MAX(K1_TSENSOR_THRSH_HIGH_MASK));
|
||||
if (low >= high)
|
||||
return -EINVAL;
|
||||
|
||||
val = readl(ts->base + K1_TSENSOR_THRSH_REG(ch->id));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user