]> git.ipfire.org Git - thirdparty/linux.git/commit
hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible()
authorSanman Pradhan <psanman@juniper.net>
Mon, 23 Mar 2026 00:24:37 +0000 (00:24 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 24 Mar 2026 14:55:34 +0000 (07:55 -0700)
commitb0c9d8ae71509f25690d57f2efddebf7f4b12194
treef76793056986f4efc22f84a132e535c26250d971
parent0adc752b4f7d82af7bd14f7cad3091b3b5d702ba
hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible()

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>
Link: https://lore.kernel.org/r/20260323002352.93417-3-sanman.pradhan@hpe.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/peci/cputemp.c