Skip to content

Commit b0c9d8a

Browse files
Sanman Pradhangroeck
authored andcommitted
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: bf3608f ("hwmon: peci: Add cputemp driver") Cc: [email protected] Signed-off-by: Sanman Pradhan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 0adc752 commit b0c9d8a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/hwmon/peci/cputemp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static umode_t cputemp_is_visible(const void *data, enum hwmon_sensor_types type
319319
{
320320
const struct peci_cputemp *priv = data;
321321

322-
if (channel > CPUTEMP_CHANNEL_NUMS)
322+
if (channel >= CPUTEMP_CHANNEL_NUMS)
323323
return 0;
324324

325325
if (channel < channel_core)

0 commit comments

Comments
 (0)