mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Pradhan, Sanman" <sanman.pradhan@hpe.com>
To: "linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>
Cc: "linux@roeck-us.net" <linux@roeck-us.net>,
	"iwona.winiarska@intel.com" <iwona.winiarska@intel.com>,
	"corbet@lwn.net" <corbet@lwn.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Sanman Pradhan <psanman@juniper.net>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [PATCH 2/2] hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible()
Date: Mon, 23 Mar 2026 00:24:37 +0000	[thread overview]
Message-ID: <20260323002352.93417-3-sanman.pradhan@hpe.com> (raw)
In-Reply-To: <20260323002352.93417-1-sanman.pradhan@hpe.com>

From: Sanman Pradhan <psanman@juniper.net>

cputemp_is_visible() validates the channel index against
CPUTEMP_CHANNEL_NUMS, but currently uses '>' instead of '>='.
As a result, channel == CPUTEMP_CHANNEL_NUMS is not rejected even though
valid indices are 0 .. CPUTEMP_CHANNEL_NUMS - 1.

Fix the bounds check by using '>=' so invalid channel indices are
rejected before indexing the core bitmap.

Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
---
 drivers/hwmon/peci/cputemp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c
index badec53ff4461..457089c561b40 100644
--- a/drivers/hwmon/peci/cputemp.c
+++ b/drivers/hwmon/peci/cputemp.c
@@ -319,7 +319,7 @@ static umode_t cputemp_is_visible(const void *data, enum hwmon_sensor_types type
 {
 	const struct peci_cputemp *priv = data;
 
-	if (channel > CPUTEMP_CHANNEL_NUMS)
+	if (channel >= CPUTEMP_CHANNEL_NUMS)
 		return 0;
 
 	if (channel < channel_core)
-- 
2.34.1


  parent reply	other threads:[~2026-03-23  0:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23  0:24 [PATCH 0/2] hwmon: (peci/cputemp) Fix temp*_crit_hyst and cputemp_is_visible() bounds check Pradhan, Sanman
2026-03-23  0:24 ` [PATCH 1/2] hwmon: (peci/cputemp) Fix crit_hyst returning delta instead of absolute temperature Pradhan, Sanman
2026-03-23  1:40   ` Guenter Roeck
2026-03-23  0:24 ` Pradhan, Sanman [this message]
2026-03-23  1:40   ` [PATCH 2/2] hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible() Guenter Roeck

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=20260323002352.93417-3-sanman.pradhan@hpe.com \
    --to=sanman.pradhan@hpe.com \
    --cc=corbet@lwn.net \
    --cc=iwona.winiarska@intel.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=psanman@juniper.net \
    --cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®