diff options
| author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2020-12-15 10:20:30 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-01-19 18:27:25 +0100 |
| commit | 3163d7c1fbd32d96d242557ad443fe595a9ee281 (patch) | |
| tree | 6ed90e3e1c191be1f05f83b23fe43d952eec9243 /scripts | |
| parent | 8c3520e21f6b048901534463233d7aa73900a112 (diff) | |
hwmon: (pwm-fan) Ensure that calculation doesn't discard big period values
[ Upstream commit 1eda52334e6d13eb1a85f713ce06dd39342b5020 ]
With MAX_PWM being defined to 255 the code
unsigned long period;
...
period = ctx->pwm->args.period;
state.duty_cycle = DIV_ROUND_UP(pwm * (period - 1), MAX_PWM);
calculates a too small value for duty_cycle if the configured period is
big (either by discarding the 64 bit value ctx->pwm->args.period or by
overflowing the multiplication). As this results in a too slow fan and
so maybe an overheating machine better be safe than sorry and error out
in .probe.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20201215092031.152243-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions
