Skip to content

Commit

Permalink
hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Evgeny Novikov authored and Guenter Roeck committed Jul 6, 2020
1 parent dcb7fd8 commit bc4071a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/hwmon/aspeed-pwm-tacho.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit bc4071a

Please sign in to comment.