* [PATCH] hwmon: (it87) Bound 16-bit fan limits before conversion
@ 2026-11-09 10:17 Zhu Jun
2026-11-09 10:21 ` sashiko-bot
0 siblings, 1 reply; 4+ messages in thread
From: Zhu Jun @ 2026-11-09 10:17 UTC (permalink / raw)
To: jdelvare; +Cc: linux, linux-hwmon, linux-kernel
FAN16_TO_REG() doubles an unrestricted positive long and adds 1350000
before dividing. Large fan limits can overflow these intermediate values
and select an incorrect tachometer limit. Converting LONG_MAX can select
0xfffe instead of 1.
Apply the same RPM bound used by the 8-bit conversion before doing the
arithmetic. Keep zero as the alarm-disable value.
Fixes: 17d648bf5786 ("it87: Add support for the IT8716F")
---
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/it87.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index bbb3f9788c2e..b8ad1ed043b3 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -761,6 +761,7 @@ static inline u16 FAN16_TO_REG(long rpm)
{
if (rpm == 0)
return 0xffff;
+ rpm = clamp_val(rpm, 1, 1000000);
return clamp_val((1350000 + rpm) / (rpm * 2), 1, 0xfffe);
}
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] hwmon: (it87) Bound 16-bit fan limits before conversion
@ 2026-11-11 6:52 Zhu Jun
2026-11-11 6:59 ` sashiko-bot
0 siblings, 1 reply; 4+ messages in thread
From: Zhu Jun @ 2026-11-11 6:52 UTC (permalink / raw)
To: jdelvare; +Cc: linux, linux-hwmon, linux-kernel, Zhu Jun
FAN16_TO_REG() doubles an unrestricted positive long and adds 1350000
before dividing. Large fan limits can overflow these intermediate values
and select an incorrect tachometer limit. Converting LONG_MAX can select
0xfffe instead of 1.
Apply the same RPM bound used by the 8-bit conversion before doing the
arithmetic. Keep zero as the alarm-disable value.
Fixes: 17d648bf5786 ("it87: Add support for the IT8716F")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
drivers/hwmon/it87.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index bbb3f9788c2e..b8ad1ed043b3 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -761,6 +761,7 @@ static inline u16 FAN16_TO_REG(long rpm)
{
if (rpm == 0)
return 0xffff;
+ rpm = clamp_val(rpm, 1, 1000000);
return clamp_val((1350000 + rpm) / (rpm * 2), 1, 0xfffe);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-11 6:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 10:17 [PATCH] hwmon: (it87) Bound 16-bit fan limits before conversion Zhu Jun
2026-11-09 10:21 ` sashiko-bot
-- strict thread matches above, loose matches on Subject: below --
2026-11-11 6:52 Zhu Jun
2026-11-11 6:59 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox