diff options
author | Colin Ian King <colin.king@canonical.com> | 2021-09-20 20:09:21 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2021-10-12 16:22:38 +0200 |
commit | 000cc5bc49aafc83a131bab2becf9922f5eec658 (patch) | |
tree | b867604686d9f1146ea8bb5aa412477f5280647c /drivers/hwmon/mlxreg-fan.c | |
parent | hwmon: (nct6775) Support access via Asus WMI (diff) | |
download | linux-000cc5bc49aafc83a131bab2becf9922f5eec658.tar.xz linux-000cc5bc49aafc83a131bab2becf9922f5eec658.zip |
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: 35edbaab3bbf ("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>
Diffstat (limited to 'drivers/hwmon/mlxreg-fan.c')
-rw-r--r-- | drivers/hwmon/mlxreg-fan.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c index 35228ed112d7..feab9ec6a6ca 100644 --- a/drivers/hwmon/mlxreg-fan.c +++ b/drivers/hwmon/mlxreg-fan.c @@ -554,7 +554,7 @@ static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan) { int i, j; - for (i = 0; i <= MLXREG_FAN_MAX_PWM; i++) { + for (i = 0; i < MLXREG_FAN_MAX_PWM; i++) { struct mlxreg_fan_pwm *pwm = &fan->pwm[i]; if (!pwm->connected) |