[PATCH v4 4/5] platform/x86: hp-wmi: fix u8 underflow in gpu_delta calculation

From: Emre Cecanpunar

Date: Tue Apr 07 2026 - 10:28:19 EST


gpu_delta was declared as u8. If the firmware specifies a GPU RPM
lower than the CPU RPM, subtracting them causes an underflow
(e.g. 10 - 20 = 246), which forces the GPU fan to remain clamped at
U8_MAX (100% speed) during operation.

Change gpu_delta to int and use signed arithmetic. Existing signed logic
in hp_wmi_fan_speed_set() correctly handles negative deltas.

Fixes: 46be1453e6e6 ("platform/x86: hp-wmi: add manual fan control for Victus S models")
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
Signed-off-by: Emre Cecanpunar <emreleno@xxxxxxxxx>
---
Changes in v4:
- Restore gpu_delta assignment to a single line to avoid unrelated style noise.
- This results in the assignment being identical to the base branch, effectively
removing that hunk from the patch while keeping the type change.

Changes in v3:
- Remove unnecessary casting.
- Add Fixes: tag.

Changes in v2:
- Change gpu_delta type to int to handle potential negative values.

drivers/platform/x86/hp/hp-wmi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 2932cab9aa78..4f49861d3fbe 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -455,7 +455,7 @@ enum pwm_modes {
struct hp_wmi_hwmon_priv {
u8 min_rpm;
u8 max_rpm;
- u8 gpu_delta;
+ int gpu_delta;
u8 mode;
u8 pwm;
struct delayed_work keep_alive_dwork;
@@ -2549,8 +2549,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;
--
2.53.0