From nobody Tue Sep 29 01:18:18 2026 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 19494345EBF for ; Thu, 13 Aug 2026 21:20:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786656035; cv=none; b=Gy8hddxyCIgrKmR1Nfj5/pCiW6x34KgZHOwQfGV1AdCi0HQ/HsiJ2Rhoiq7UyK5wfxfFme8O0xzO87MJ5KVuc5iOhVm6mEKowMSxqFjzQlgxxpXoMfRRjJfE7whRT6SWK5wFDA41fmOMEAKIDcYzF8IY/3m2tui1LjtslLhIKZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786656035; c=relaxed/simple; bh=CybgFQe+3LKwO+ojdV6IbLmwtUs6c1R2LVZh9Nd58to=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DzkraDml8/SWDHibjbiLRP9P+zv5WW28Cr+3W2sjCpl8WxAvFNXLJrAFO0wnuRmCEXonKwo5cr6Fq9DN4Z33xCDXqRaml/vO5P70j/J1nXndKkwhVji+xNXuuO+BZI3Ba4zYw0KiTcXkqsDIt1aKw36BY6WrJWkcRXCLsBBePfU= 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=aFXZdZEv; arc=none smtp.client-ip=209.85.218.52 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="aFXZdZEv" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-c1600d040e4so35811866b.1 for ; Thu, 13 Aug 2026 14:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786656029; x=1787260829; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=BIkgaHZoj6aDIeZUHMoRey9Gqj9yPB6NQRSWVTdMP0o=; b=aFXZdZEvvV9wyXrubcdwanrf2ks/Ko2yNIDlZ18UarLNFfDUkqntuCCKo8ni/LEnyY AFw3lPircDG9c3EqlhPvprrzwjAx+vrMBtO69kC1PGfaDLbthwZsxbp9fdgETm0EaNr8 KI1VvCRXUWAUMiixE7LVPAZ48cSaOMtJbw8NIulkOdpj262dmv2w2b7Tp9HowtZStQV4 9ib+ERRCbbL/O9Jj76i46NXyGnJbWtrO+tFwBP7rLpZ+oJzB7PCstzWEz98HOlcGuhK0 /NpZYC7Y4FrAqMBJc3JP3Bqt+jZCpxDksGt0ADqArM+ykkdCzk9LSs/agniUGJnp4Y5J oRAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786656029; x=1787260829; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=BIkgaHZoj6aDIeZUHMoRey9Gqj9yPB6NQRSWVTdMP0o=; b=eSzheXS3n0Y4jc6JLBipKlMK3iA/cWECRrzaZwu3WemljAbarh+15tSyUMZw9u7quq XL+OpAub49mj/CER68dyApJF/wRquWc7IJ4wN31mCm1J079cYQ8oU8Qt2Wj/TaFSNDeo v6A4SALKiszKvHfpbGHzEigiTxAmNxl1BMVkc0BXomtvUX4MEFqv5rcx3ToFDruyTX6c H9pZl0dwF4thZupMvfpv6JN8bI4KTgd9kJBZYtN3hzWzfEtF+K72MztxVlUaM81FpPui vbOP37XTtkN/mQcxzc70s4vVORaOYIos0rXUNxf1QwW+bFgdWUyZh9XnXRM5z7vJMq4g np1Q== X-Forwarded-Encrypted: i=1; AHgh+RqXe7x5qT3eqfaX/8aOATjEbFyHgIaOkJZIqlwhIWSZc78UmySjDnXxVUVblu0F90GKS0I9OJ8ErMYW5AA=@vger.kernel.org X-Gm-Message-State: AOJu0YzWTEqspviFpWLxUMhImsPqNWO80/++ACdiRrNykroxW3k4qxyz pJGyGqg6kuqoqhKyGGtdMuthfIMMaRliVtbKRWmGB27p+LLYUEO24l4= X-Gm-Gg: AR+sD11hafIvTNdJH1MmfP1f6A65y2YqkgfqXfRHkD6bN46GU++jG+/Qv9bMGUDrpz3 u1WrwAVgAGGZFGm2oWkMYgUelW4OGJVJsOeOwiZi9og7GGp6dD452Lth+bDu+cbeKZ61L9U54pc 8OXEliL0IHCTYhSH4wyu0yRySlpKmJyukdGPS+YdOjVnu2nQ3IjNLMb7N3hm6fjcT1c9oCka2kZ ch6w7nhBjEeBCAQdaKjkvlDVC3FUMh/dwQ8YyT+7SICcM+/kavd5K1GeF5CJXIb7pXkONn+0ZLx yGVP6dz+xVBeMyUnC8Rby2AUv64Xq+zdFeACyCw2yta0yhCVWGgdeurjpJLwk/eLacbhurJIS1C 3eUriU9Y9+eszEG2JbIDlcPpsBihMkUnipFA9DLxZOv57dRleiR91uv1F3cpyBD2lloF0sT5A6A QXZSH1/xjDKo97/6+p2cGrqI5Lvg6ozP5lGMG8DxirGSGcxEK8gy+cqIPTJIjimPLpGt1lDWSJX vO9nGmNGbO+AyiqQR/VrZmbSvKr1vaALxysDg== X-Received: by 2002:a17:906:ef01:b0:c0d:7c31:26a9 with SMTP id a640c23a62f3a-c212a22bfcfmr50240866b.2.1786656029024; Thu, 13 Aug 2026 14:20:29 -0700 (PDT) Received: from arch.tail2fcf52.ts.net (223-143-146-85.ftth.glasoperator.nl. [85.146.143.223]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c21233a12e6sm32475466b.12.2026.08.13.14.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2026 14:20:28 -0700 (PDT) From: Mark Sercombe To: linux@roeck-us.net Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Sercombe Subject: [PATCH] hwmon: (w83627hf) fix out of bounds read of PWM register array Date: Thu, 13 Aug 2026 23:19:50 +0200 Message-ID: <20260813211950.535148-1-sercombe.joel.mark@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" w83627hf_update_device() reads PWM registers in a loop bounded by a hard coded "i <=3D 2", i.e. three iterations, for every chip type. For the W83627HF, W836X7HF_REG_PWM() indexes regpwm_627hf[], which only has two entries. The third iteration therefore reads regpwm_627hf[2], one element past the end of the array, and issues a read of a non existent PWM register. The W83627HF has only two PWM outputs (datasheet registers CR5A and CR5B, corresponding to W83627HF_REG_PWM1/PWM2) it has no third PWM register, and the driver correctly does not expose pwm3 for this chip. The function already computes num_pwms for this purpose, but the loop did not use it, and num_pwms itself did not account for the W83627HF having two PWMs. Include the W83627HF in the two PWM case and bound the loop by num_pwms so each chip only reads the PWM registers it actually has. Found by smatch. Compile tested only, I do not have the hardware. Signed-off-by: Mark Sercombe --- drivers/hwmon/w83627hf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index bb993bb09f40..e2cb7e8aeae3 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -478,7 +478,7 @@ static struct w83627hf_data *w83627hf_update_device(str= uct device *dev) { struct w83627hf_data *data =3D dev_get_drvdata(dev); int i, num_temps =3D (data->type =3D=3D w83697hf) ? 2 : 3; - int num_pwms =3D (data->type =3D=3D w83697hf) ? 2 : 3; + int num_pwms =3D (data->type =3D=3D w83627hf || data->type =3D=3D w83697h= f) ? 2 : 3; =20 mutex_lock(&data->update_lock); =20 @@ -506,7 +506,7 @@ static struct w83627hf_data *w83627hf_update_device(str= uct device *dev) w83627hf_read_value(data, W83627HF_REG_FAN_MIN(i)); } - for (i =3D 0; i <=3D 2; i++) { + for (i =3D 0; i < num_pwms; i++) { u8 tmp =3D w83627hf_read_value(data, W836X7HF_REG_PWM(data->type, i)); /* bits 0-3 are reserved in 627THF */ --=20 2.55.0