Commit 73ebf5be authored by Evgeny Novikov's avatar Evgeny Novikov Committed by Greg Kroah-Hartman

hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow

[ Upstream commit bc4071aa ]

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: default avatarEvgeny Novikov <novikov@ispras.ru>
Link: https://lore.kernel.org/r/20200703111518.9644-1-novikov@ispras.ruSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 545f4f98
...@@ -880,6 +880,8 @@ static int aspeed_create_fan(struct device *dev, ...@@ -880,6 +880,8 @@ static int aspeed_create_fan(struct device *dev,
ret = of_property_read_u32(child, "reg", &pwm_port); ret = of_property_read_u32(child, "reg", &pwm_port);
if (ret) if (ret)
return ret; return ret;
if (pwm_port >= ARRAY_SIZE(pwm_port_params))
return -EINVAL;
aspeed_create_pwm_port(priv, (u8)pwm_port); aspeed_create_pwm_port(priv, (u8)pwm_port);
ret = of_property_count_u8_elems(child, "cooling-levels"); ret = of_property_count_u8_elems(child, "cooling-levels");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment