diff options
author | Evgeny Novikov <novikov@ispras.ru> | 2020-07-03 14:15:18 +0300 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2020-07-05 20:45:45 -0700 |
commit | bc4071aafcf4d0535ee423b69167696d6c03207d (patch) | |
tree | a7da81abecf0e40eba32bc94a062c605f18c6bb6 /drivers/hwmon | |
parent | dcb7fd82c75ee2d6e6f9d8cc71c52519ed52e258 (diff) | |
download | linux-stable-bc4071aafcf4d0535ee423b69167696d6c03207d.tar.gz linux-stable-bc4071aafcf4d0535ee423b69167696d6c03207d.tar.bz2 linux-stable-bc4071aafcf4d0535ee423b69167696d6c03207d.zip |
hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow
aspeed_create_fan() reads a pwm_port value using of_property_read_u32().
If pwm_port will be more than ARRAY_SIZE(pwm_port_params), there will be
a buffer overflow in
aspeed_create_pwm_port()->aspeed_set_pwm_port_enable(). The patch fixes
the potential buffer overflow.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Link: https://lore.kernel.org/r/20200703111518.9644-1-novikov@ispras.ru
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/aspeed-pwm-tacho.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index 33fb54845bf6..3d8239fd66ed 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c @@ -851,6 +851,8 @@ static int aspeed_create_fan(struct device *dev, ret = of_property_read_u32(child, "reg", &pwm_port); if (ret) return ret; + if (pwm_port >= ARRAY_SIZE(pwm_port_params)) + return -EINVAL; aspeed_create_pwm_port(priv, (u8)pwm_port); ret = of_property_count_u8_elems(child, "cooling-levels"); |