From: Emre Cecanpunar <emreleno@gmail.com>
To: platform-driver-x86@vger.kernel.org
Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com,
krishna.chomal108@gmail.com, linux-kernel@vger.kernel.org,
Emre Cecanpunar <emreleno@gmail.com>
Subject: [PATCH 4/5] platform/x86: hp-wmi: fix u8 underflow in gpu_delta calculation
Date: Sat, 21 Mar 2026 02:55:56 +0300 [thread overview]
Message-ID: <20260320235557.56298-5-emreleno@gmail.com> (raw)
In-Reply-To: <20260320235557.56298-1-emreleno@gmail.com>
gpu_delta was declared as u8 and computed as the difference of two u8
fan RPM values from the firmware fan table. If gpu_rpm < cpu_rpm, the
subtraction wraps around modulo 256, producing a large positive value
(e.g. 10 - 20 = 246 as u8). This value is then added to every
requested fan speed in hp_wmi_fan_speed_set(), causing the GPU fan to
be clamped to U8_MAX on almost every write.
The fan table originates from an undocumented WMI interface; a
firmware bug or unexpected layout could produce this condition.
Change gpu_delta to int and perform the subtraction in signed
arithmetic. On underflow, emit a warning and treat the delta as zero
so the GPU fan tracks the CPU fan directly rather than saturating.
Signed-off-by: Emre Cecanpunar <emreleno@gmail.com>
---
drivers/platform/x86/hp/hp-wmi.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index a29f34588055..b8f22d70e996 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -2530,8 +2530,8 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hwmon_priv *priv)
{
u8 fan_data[128] = { 0 };
struct victus_s_fan_table *fan_table;
- u8 min_rpm, max_rpm, gpu_delta;
- int ret;
+ u8 min_rpm, max_rpm;
+ int gpu_delta, ret;
/* Default behaviour on hwmon init is automatic mode */
priv->mode = PWM_MODE_AUTO;
@@ -2553,10 +2553,15 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hwmon_priv *priv)
min_rpm = fan_table->entries[0].cpu_rpm;
max_rpm = fan_table->entries[fan_table->header.num_entries - 1].cpu_rpm;
- gpu_delta = fan_table->entries[0].gpu_rpm - fan_table->entries[0].cpu_rpm;
+ gpu_delta = (int)fan_table->entries[0].gpu_rpm -
+ (int)fan_table->entries[0].cpu_rpm;
+ if (gpu_delta < 0) {
+ pr_warn("fan table has gpu_rpm < cpu_rpm, ignoring gpu delta\n");
+ gpu_delta = 0;
+ }
priv->min_rpm = min_rpm;
priv->max_rpm = max_rpm;
- priv->gpu_delta = gpu_delta;
+ priv->gpu_delta = (u8)gpu_delta;
return 0;
}
--
2.53.0
next prev parent reply other threads:[~2026-03-20 23:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 23:55 [PATCH 0/5] platform/x86: hp-wmi: fix bugs in Victus S fan control Emre Cecanpunar
2026-03-20 23:55 ` [PATCH 1/5] platform/x86: hp-wmi: fix ignored return values in fan settings Emre Cecanpunar
2026-03-20 23:55 ` [PATCH 2/5] platform/x86: hp-wmi: avoid cancel_delayed_work_sync from work handler Emre Cecanpunar
2026-03-20 23:55 ` [PATCH 3/5] platform/x86: hp-wmi: use mod_delayed_work to reset keep-alive timer Emre Cecanpunar
2026-03-20 23:55 ` Emre Cecanpunar [this message]
2026-03-22 17:14 ` [PATCH 4/5] platform/x86: hp-wmi: fix u8 underflow in gpu_delta calculation Krishna Chomal
2026-03-20 23:55 ` [PATCH 5/5] platform/x86: hp-wmi: add locking for concurrent hwmon access Emre Cecanpunar
2026-03-22 16:27 ` [PATCH 0/5] platform/x86: hp-wmi: fix bugs in Victus S fan control Krishna Chomal
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=20260320235557.56298-5-emreleno@gmail.com \
--to=emreleno@gmail.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=krishna.chomal108@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.