[PATCH 2/2] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take

From: Rosen Penev

Date: Sat Nov 14 2026 - 01:20:54 EST


The fan_max module parameter is used without any range check, unlike
fan_mult. dell_smm_init_hwmon() allocates the nominal speed table with

devm_kmalloc_array(dev, data->i8k_fan_max + 1, ...)

and fan_max=4294967295 wraps the count to 0. devm_kmalloc() then
returns ZERO_SIZE_PTR, which the first successful nominal speed call
writes through.

Values above 255 are also meaningless: the fan state is passed to the
BIOS as fan | (speed << 8), so the higher bits end up in other parts of
the request. Large values that do not wrap still cost one SMM call per
state and fan while probing.

Fail probing if the maximum fan state does not fit in a byte, like the
existing check for fan_mult.

Fixes: 81474fc2fae9 ("i8k: Add support for configurable maximum fan speed value")
Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
drivers/hwmon/dell-smm-hwmon.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index e8b4e8a29e8b..24a9172b7fed 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -1249,6 +1249,12 @@ static int dell_smm_init_data(struct device *dev, const struct dell_smm_ops *ops
return -EINVAL;
}
data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH;
+ /* The BIOS takes the fan state in a single byte */
+ if (data->i8k_fan_max > U8_MAX) {
+ dev_err(dev, "maximum fan state %u is too large (max %u)\n",
+ data->i8k_fan_max, U8_MAX);
+ return -EINVAL;
+ }
data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max);

return 0;
--
2.56.0