From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB0823BE634 for ; Tue, 7 Apr 2026 14:25:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571946; cv=none; b=MeB2ytJgc+jrAo25WgouAN0jdPGvzh0KUasI6I5H+Ew905KA8AivXJOp3vMX/t5xeJObY1hAmYo9jjuKoqTlW9U+VT3TXK6XuktWZO9UVLiUciNKo0SB+GsOeJZhVZSsYNENzY9wNjqD2WZ4FX5r1RSBfLLustmqJ7NCsbjyFaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571946; c=relaxed/simple; bh=0xtk6l9zXJ52xBcCS8Er3MVuVDFKl38JCXDoxR2HnAA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QMu8izsGcwrCRfr7vrpyaavt6tkmBOPQHBmSo00q8iqJMjFarE2j4lwzb/qDFdrJh395R4JtQ5aRv0ir0olDhJGLPVbcUGnLbp24c9MADH1H44JPIEEBrDhvqnOTXgRWVDjUB3/ZepZzb+brtK8s21XYMfaapm5WTDptK10kPJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B81cm8t6; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B81cm8t6" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-43cf5ba9b93so599862f8f.2 for ; Tue, 07 Apr 2026 07:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775571943; x=1776176743; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TqshKVQ1S707dYaNTrTbQfEtf4ZgIgsOHm40TNLvX7s=; b=B81cm8t6tAuDgvt4vsjLA8gm/w8+/3PFg3TAuR0xKcqCBDU6eGJzPdIRop0grEne3J 5pK7iCZnVcoxRNJ7h8Qrp0PFofkLqMcImqwRy7A4NmhJVFxRTnh7/EgXAu7MdzjFEm91 7yTBX/K/Ws/bA+JfnfOH21Mvjpr9pqpmLedxMSxEgd6qq3DJQ71vMR/QzP9DkKLgxeIi v63QczegJfTKiWd46DuQWpDJjFmAIpMNTQdkj0RsnyZc/09uwXenGn7CwD6O3OC9UyDQ I3j/fmUlRT60oCKrIo4fR3bxKjKJvfEZKkhPAyIoQSGwXQOYDhFjEWyXa6N7dSa48+s5 khoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775571943; x=1776176743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TqshKVQ1S707dYaNTrTbQfEtf4ZgIgsOHm40TNLvX7s=; b=se0qZ6gvLLmrf2VnqyfAcZoNR+kS35c9j5VOBX+fy0nC4m8wciiLwTKpOaK/u2ow8A R047MYkjh73I8JN5DzMcZ3ADNdFrwKFnkMHQuoSJsuNFbuoyh7dxdahCCk0HqUkpJih1 c5KVYrp0WQXImcFSSCSg5iqJk6ItQOZnP1FCJJ60QQwqHr1kd4mnLjy0ZdTZCvJH9nWc cW54Ks4qZBfW3whMomJY803uP+1Yp1NBNxAEaC7ZMfeiPhGLExoqckHI09Oec91QEhw+ 39/lFhX3ufPbK1SwwB6BHC8Xuw9zFfCboGbzMSZHWMCCzU+Qig1DfjQ1+/pI9TUuJv+2 JqRw== X-Forwarded-Encrypted: i=1; AJvYcCWn2e5mU06ifD5UbxIPFC+yQZph63CAxIhGM25oT4Nnr89l+1flafEl/J9JwrB3fysPgMvboqgrorNZFgk=@vger.kernel.org X-Gm-Message-State: AOJu0YwLCknMSQU2M40rI7bNbRXUJhTRSflkv3doHXni+edzS8mL9j66 RPv8pfvsJoH6qnxmdeV55m1FdwlpUPpdmS96N8PM2+S0ZJPBRx0EwXSQ X-Gm-Gg: AeBDieunlz8tQtyDKkBQEwi0tyHuKnABhoFLW0bJDlLV7DSysM9QeNHp1roA3QJtnK6 kbMudhYmc6MLW+whpYf8MiiC2f/e9bLu/NSfuiIYjqe/zn4wlwvXrttRqM9D2FBGef93i04Bauu TndFFGHMzCHbXGI4JUMGpICNSu33539ATbrZAcss/vSAg2dRr+wjKr1s/BR0od8zd9qgJvZ4yOC 49IHPs5svMCRgHjZJXdjd4mTGh4buIwvkzEaiPUnS4VX0C1KfR7+zOB2iGVz2R8UQfQVdmrunVE aU5f7rQBbOXm9AaPyP6xLcCjWKkEE4N02aZUC2ePalYD4DUwJEiClLozQdo5udW4bIjo7JpQDE6 PuIbJfh8Oul5tIT4Fk4dZmXC5nMG7XW8W1Dg38UhV06lzWS1OC4MJeZmlwuPWcyVFLO0HW0uapF l7cqxwbpqmZk9fcshMcfgvnAwSeZqTBsqNuQSar7Z3a27ows96pkk/leAVFj9thA== X-Received: by 2002:a05:6000:18a8:b0:43d:4cc6:77dc with SMTP id ffacd0b85a97d-43d4cc6781dmr1948333f8f.2.1775571943194; Tue, 07 Apr 2026 07:25:43 -0700 (PDT) Received: from localhost.localdomain ([31.7.38.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm53489990f8f.32.2026.04.07.07.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 07:25:42 -0700 (PDT) From: Emre Cecanpunar To: platform-driver-x86@vger.kernel.org Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, krishna.chomal108@gmail.com, edip@medip.dev, emreleno@gmail.com Subject: [PATCH v4 4/5] platform/x86: hp-wmi: fix u8 underflow in gpu_delta calculation Date: Tue, 7 Apr 2026 17:25:13 +0300 Message-ID: <20260407142515.20683-5-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260407142515.20683-1-emreleno@gmail.com> References: <20260407142515.20683-1-emreleno@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Emre Cecanpunar --- 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