Skip to content

Commit 000cc5b

Browse files
Colin Ian Kinggroeck
authored andcommitted
hwmon: (mlxreg-fan) Fix out of bounds read on array fan->pwm
Array fan->pwm[] is MLXREG_FAN_MAX_PWM elements in size, however the for-loop has a off-by-one error causing index i to be out of range causing an out of bounds read on the array. Fix this by replacing the <= operator with < in the for-loop. Addresses-Coverity: ("Out-of-bounds read") Reported-by: Vadim Pasternak <vadimp@nvidia.com> Fixes: 35edbaa ("hwmon: (mlxreg-fan) Extend driver to support multiply cooling devices") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20210920180921.16246-1-colin.king@canonical.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 3fbbfc2 commit 000cc5b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hwmon/mlxreg-fan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan)
554554
{
555555
int i, j;
556556

557-
for (i = 0; i <= MLXREG_FAN_MAX_PWM; i++) {
557+
for (i = 0; i < MLXREG_FAN_MAX_PWM; i++) {
558558
struct mlxreg_fan_pwm *pwm = &fan->pwm[i];
559559

560560
if (!pwm->connected)

0 commit comments

Comments
 (0)