From: Yufei CHENG <cd345al@gmail.com>
To: mpearson-lenovo@squebb.ca, derekjohn.clark@gmail.com
Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, Yufei CHENG <cd345al@gmail.com>
Subject: [PATCH] platform/x86: lenovo-wmi-other: fix uninitialized variable in lenovo wmi-other driver
Date: Sun, 26 Apr 2026 18:27:24 +0800 [thread overview]
Message-ID: <20260426102725.3204-1-cd345al@gmail.com> (raw)
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: 51ed34282f63fab5b3996477cc56135eb4de5284
Signed-off-by: Yufei CHENG <cd345al@gmail.com>
---
drivers/platform/x86/lenovo/wmi-other.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
index 6040f45aa..6c2febe1a 100644
--- a/drivers/platform/x86/lenovo/wmi-other.c
+++ b/drivers/platform/x86/lenovo/wmi-other.c
@@ -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)
--
2.43.0
next reply other threads:[~2026-04-26 10:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-26 10:27 Yufei CHENG [this message]
2026-04-26 12:45 ` [PATCH] platform/x86: lenovo-wmi-other: fix uninitialized variable in lenovo wmi-other driver Rong Zhang
2026-04-26 15:10 ` no name
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260426102725.3204-1-cd345al@gmail.com \
--to=cd345al@gmail.com \
--cc=derekjohn.clark@gmail.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox