diff options
| author | Linus Torvalds <[email protected]> | 2021-01-09 11:22:30 -0800 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2021-01-09 11:22:30 -0800 |
| commit | 2ff90100ace886895e4fbb2850b8d5e49d931ed6 (patch) | |
| tree | 1cba26aff578c8c8c8e73d999a49b43c1b4bae9c /drivers/hwmon/pwm-fan.c | |
| parent | f408126be7dc642102224cdb55d6533519a67c19 (diff) | |
| parent | 84e261553e6f919bf0b4d65244599ab2b41f1da5 (diff) | |
Merge tag 'hwmon-for-v5.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck:
- Fix possible KASAN issue in amd_energy driver
- Avoid configuration problem in pwm-fan driver
- Fix kernel-doc warning in sbtsi_temp documentation
* tag 'hwmon-for-v5.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
hwmon: (amd_energy) fix allocation of hwmon_channel_info config
hwmon: (pwm-fan) Ensure that calculation doesn't discard big period values
hwmon: (sbtsi_temp) Fix Documenation kernel-doc warning
Diffstat (limited to 'drivers/hwmon/pwm-fan.c')
| -rw-r--r-- | drivers/hwmon/pwm-fan.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 777439f48c14..111a91dc6b79 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -334,8 +334,18 @@ static int pwm_fan_probe(struct platform_device *pdev) ctx->pwm_value = MAX_PWM; - /* Set duty cycle to maximum allowed and enable PWM output */ pwm_init_state(ctx->pwm, &state); + /* + * __set_pwm assumes that MAX_PWM * (period - 1) fits into an unsigned + * long. Check this here to prevent the fan running at a too low + * frequency. + */ + if (state.period > ULONG_MAX / MAX_PWM + 1) { + dev_err(dev, "Configured period too big\n"); + return -EINVAL; + } + + /* Set duty cycle to maximum allowed and enable PWM output */ state.duty_cycle = ctx->pwm->args.period - 1; state.enabled = true; |