From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 CB0E61C5F39 for ; Sun, 26 Apr 2026 16:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777222253; cv=none; b=FSty5VuMwWcvlC3JJTObK2zmb/DYehxDcLIRl7b2rINDn/B8RUNBI3p6XJFDyfSdeoN8PaLUcFgEDvO7M60O9oEXF9KlnWns5XGO8VJ4dmCJJEC8qBOA0WqSt4Ki3lop17LwgbHDSHloE0vPThvO6NNNdqvBt+QlnIDnGvmrVDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777222253; c=relaxed/simple; bh=V6Nfk52TQQCQjoetYj/INSS3ZdBJaRTflIgoGUHmLu4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lI4kPzXnsqOvlm3lH+yMccC8jtGeTdALj/yesLtrxXlUC/7f89rktiKF+4NzljBdKYzIJJjWKpoQwqkq/qkaQFhRIFXlulSQJadMGRc/MtlcmNPBdiveRSXJ6GhqatfRPLLRyG9B+0z+6rkKoPLOaatQ1fjf8OiIkMsPNokJZFw= 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=fpCVYNC7; arc=none smtp.client-ip=209.85.214.175 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="fpCVYNC7" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2b4583f0a1aso58747875ad.3 for ; Sun, 26 Apr 2026 09:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777222251; x=1777827051; 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=lKPk8+mfHJCvfB6gJz0v484ZpE6x/XUkKSomVW1TQVg=; b=fpCVYNC7It/clzcVjApDpkzL6E+TIA/4ce+WayATk/VYOJKOaGqJFfEdmmrNMynIBv Ygq3Q9odXURHkPPBEr4tTT2G4fh1vIsqZOb1nqNMYY33rXWVA4sANu08BlHg2TIlzwjy zg4rEifaY4kkfp18qQkF2ol3xa5amqAP/VZPjf+vgPsDdmq+1DHmaqAkHWmif1suK373 CZe7C8XU6nP8AOXK9ayfPmhzKTKMXhq456bh667HNs0r4lwSTWSAFGTd00Ojpac8Myjn J2Wlux/q0GaDen2w/SCH4lFixc9kclXGX91vgcWA6ulTGJ/8zOLt8sJGs4lgl48Y7oN9 XnSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777222251; x=1777827051; 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=lKPk8+mfHJCvfB6gJz0v484ZpE6x/XUkKSomVW1TQVg=; b=hT7mZqvlU/3o2Tspn1ZBLo8ypBKKw+/0bEjjO95UNKrSwGIXwtq7rhFLcsXoA2SOuV SLYxF5AdZtQQ4C+lZsh+rdaT3Mf9GP/32cwFrKn5JIsqgbd3tvl0mkQCcobZ6b5cmro/ HLwSJgdQeG3zzwAfizxKaQcQr4pL6SJM7l/v6K6iRo90/X6EVK+9M1vb8meKfEu3yiE7 5BsrrT+z4Cgmi6Xad/dDsRbFFfhisSEae4Ip8fRA13cIzSpIgo4AKn51XLxUOpT6+YqB 4Ldt1k7d9goCF7EjfwPn1vK/KwB2ym5sI8ysjQUBpxx3d6dSqoW6QhPFgcM+jb65X4bC MKtQ== X-Forwarded-Encrypted: i=1; AFNElJ+Xa9tBnKvGFECb2EsrcQP5OMtZgkEYEfPPUi01TwlBOzVeRPhBvQdVYw2xO4tgO0tTa1f4bGzQkQYNloE=@vger.kernel.org X-Gm-Message-State: AOJu0Ywk15KvwF3AAdHsQ5Ga0HCpYlB/XfkPdTBLbQzatTIcue4Iq332 y66zBB8c3I8rgzkYk0z2zF1blmCHSPkNEs0KElNBIghkNrJpywExlWqJ X-Gm-Gg: AeBDiescupfpi4u7fFAdcqulLQMuB/xlmft7B+Pn47+eT/gmejD9OvW8A99OnjfcHFt IgbsdoT86Wj30+1PrsfReoukTWLewS7fGH6ox1o0NPMJr0KchjhEoaXl+3/I6iuRmR3sMQ3fHiS +BU5KjgOMo1oAUxHY8qPyNAnYkcAm5/gkqZu+TD1kRydMDaIMhikGgfabgkkoorELZcVhCkUgCH AwIY/mOq11oak5btJiv6s4MkYHMfULCL66+NaPVkhAOxK+ynhThvDZ0PNw63+bSonM3/jov46va wD2qKDBJHIxlu5VoPVayAClwFK0hqR0gIZu7JI7UKwYr18DEHcoEUrcbH9uL/WtNLFb89zrz8mp R91Op5QfXgfRf6yUrPyrAEcfffDReH2DWSZwv2CY0CBP+qc9GxYh+Ks0R+YU1wxU3UjFXdlEOsv lEt5vhYrMNWo+nYZhAJl6+BfHb49gc4bnocN8EViJTp+sLIAs= X-Received: by 2002:a17:902:bf0b:b0:2b2:4b4e:e4d2 with SMTP id d9443c01a7336-2b5f9ede672mr282186845ad.15.1777222251037; Sun, 26 Apr 2026 09:50:51 -0700 (PDT) Received: from LAPTOP-DV5I1MV.localdomain ([27.19.123.93]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5faa30047sm289178955ad.28.2026.04.26.09.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 09:50:50 -0700 (PDT) From: Yufei CHENG To: mpearson-lenovo@squebb.ca, derekjohn.clark@gmail.com, i@rong.moe Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Yufei CHENG Subject: [PATCH v3] platform/x86: lenovo: wmi-other: Fix uninitialized variable in lwmi_om_hwmon_write() Date: Mon, 27 Apr 2026 00:50:34 +0800 Message-ID: <20260426165034.9073-1-cd345al@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260426145907.7295-1-cd345al@gmail.com> References: <20260426145907.7295-1-cd345al@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Yufei CHENG --- v3: fix broken format v2: rewrite the title to be more specific 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 6040f45aa2b..6c2febe1a59 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