Re: [PATCH 2/2] hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible()
From: Guenter Roeck
Date: Sun Mar 22 2026 - 21:44:10 EST
On Mon, Mar 23, 2026 at 12:24:37AM +0000, Pradhan, Sanman wrote:
> From: Sanman Pradhan <psanman@xxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxxxx
> Signed-off-by: Sanman Pradhan <psanman@xxxxxxxxxxx>
Applied.
Thanks,
Guenter