]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
platform/x86: lenovo: wmi-other: Fix uninitialized variable in lwmi_om_hwmon_write()
authorYufei CHENG <cd345al@gmail.com>
Sun, 26 Apr 2026 16:50:34 +0000 (00:50 +0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 30 Apr 2026 12:41:18 +0000 (15:41 +0300)
When the flag relax_fan_constraint is set, local variable 'raw'
is never assigned, and lwmi_om_hwmon_write() will pass uninitialized
value to lwmi_om_fan_get_set() resulting in undefined behavior.

This flag allows user to bypass minimum fan RPM divisor rounding,
but assignment to 'raw' only happens in the non-relaxed path.
Fix by defaulting 'raw' to user provided 'val' in the else branch.

Fixes: 51ed34282f63 ("platform/x86: lenovo-wmi-other: Add HWMON for fan reporting/tuning")
Reviewed-by: Rong Zhang <i@rong.moe>
Signed-off-by: Yufei CHENG <cd345al@gmail.com>
Link: https://patch.msgid.link/20260426165034.9073-1-cd345al@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/lenovo/wmi-other.c

index 6040f45aa2b0d63696af8520ca9653d52cb4cc1e..6c2febe1a595caa8a3dd85a91d4233e3c0240738 100644 (file)
@@ -349,6 +349,8 @@ static int lwmi_om_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
                         */
                        if (!relax_fan_constraint)
                                raw = val / LWMI_FAN_DIV * LWMI_FAN_DIV;
+                       else
+                               raw = val;
 
                        err = lwmi_om_fan_get_set(priv, channel, &raw, true);
                        if (err)