Skip to content
Commit 0babf89c authored by Nikita Zhandarovich's avatar Nikita Zhandarovich Committed by Guenter Roeck
Browse files

hwmon: (f71882fg) prevent possible division by zero



In the unlikely event that something goes wrong with the device and
its registers, the fan_from_reg() function may return 0. This value
will cause a division-by-zero error in the show_pwm() function.

To prevent this, test the value of
fan_from_reg(data->fan_full_speed[nr]) against 0 before performing
the division. If the division-by-zero error is avoided, assign 0 to
the val variable.

Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.

Fixes: df9ec2da ("hwmon: (f71882fg) Reorder symbols to get rid of a few forward declarations")
Signed-off-by: default avatarNikita Zhandarovich <n.zhandarovich@fintech.ru>
Link: https://lore.kernel.org/r/20230510143537.145060-1-n.zhandarovich@fintech.ru


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent f1fcbaa1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment