Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH] hwmon: (lm85) Bound fan stop temperatures before subtraction
@ 2026-11-11  6:53 Zhu Jun
  2026-11-11  7:06 ` sashiko-bot
  2026-11-11 16:57 ` Guenter Roeck
  0 siblings, 2 replies; 6+ messages in thread
From: Zhu Jun @ 2026-11-11  6:53 UTC (permalink / raw)
  To: linux; +Cc: linux-hwmon, linux-kernel, Zhu Jun

temp_auto_temp_off_store() subtracts an unrestricted long from the zone
limit before clamping the resulting hysteresis. Extreme inputs can
overflow this subtraction and select the wrong end of the hysteresis
range.

Bound the requested stop temperature before calculating the difference.
A signed 8-bit zone limit and a maximum hysteresis of 15 degrees require
only the -143..127 degree range.

Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 drivers/hwmon/lm85.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 80bd1f47114d..e776ec4ae40f 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -1153,6 +1153,7 @@ static ssize_t temp_auto_temp_off_store(struct device *dev,
 
 	mutex_lock(&data->update_lock);
 	min = TEMP_FROM_REG(data->zone[nr].limit);
+	val = clamp_val(val, -128000 - 15000, 127000);
 	data->zone[nr].hyst = HYST_TO_REG(min - val);
 	if (nr == 0 || nr == 1) {
 		lm85_write_value(client, LM85_REG_AFAN_HYST1,
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] hwmon: (lm85) Bound fan stop temperatures before subtraction
@ 2026-11-09 10:19 Zhu Jun
  2026-11-09 10:26 ` sashiko-bot
  2026-11-09 15:12 ` Guenter Roeck
  0 siblings, 2 replies; 6+ messages in thread
From: Zhu Jun @ 2026-11-09 10:19 UTC (permalink / raw)
  To: linux; +Cc: linux-hwmon, linux-kernel

temp_auto_temp_off_store() subtracts an unrestricted long from the zone
limit before clamping the resulting hysteresis. Extreme inputs can
overflow this subtraction and select the wrong end of the hysteresis
range.

Bound the requested stop temperature before calculating the difference.
A signed 8-bit zone limit and a maximum hysteresis of 15 degrees require
only the -143..127 degree range.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
Validation: x86-64 and i386 driver objects built with W=1.
Source-extracted boundary tests passed on both word sizes;
the corresponding test fails on the base revision. I/O is mocked.
No physical sensor or booted-kernel testing was available.
OpenAI Codex assisted analysis, code, tests and changelog drafting.
Please review and add your own Signed-off-by before submitting.

 drivers/hwmon/lm85.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 80bd1f47114d..e776ec4ae40f 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -1153,6 +1153,7 @@ static ssize_t temp_auto_temp_off_store(struct device *dev,
 
 	mutex_lock(&data->update_lock);
 	min = TEMP_FROM_REG(data->zone[nr].limit);
+	val = clamp_val(val, -128000 - 15000, 127000);
 	data->zone[nr].hyst = HYST_TO_REG(min - val);
 	if (nr == 0 || nr == 1) {
 		lm85_write_value(client, LM85_REG_AFAN_HYST1,

base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
-- 
2.51.0




^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-11 16:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11  6:53 [PATCH] hwmon: (lm85) Bound fan stop temperatures before subtraction Zhu Jun
2026-11-11  7:06 ` sashiko-bot
2026-11-11 16:57 ` Guenter Roeck
  -- strict thread matches above, loose matches on Subject: below --
2026-11-09 10:19 Zhu Jun
2026-11-09 10:26 ` sashiko-bot
2026-11-09 15:12 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox