diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-01-11 08:09:25 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-01-11 08:09:25 +0100 |
commit | 591afd6e5a5045a7c0fe3fc6a26c55d8030bbf9f (patch) | |
tree | 9028c6bdb3b5a2536b74deeaa4901f94ba7a3b84 /drivers/hwmon/pwm-fan.c | |
parent | 59b26d2e96c473b7b65cfe19381444d034e91715 (diff) | |
parent | 7c53f6b671f4aba70ff15e1b05148b10d58c2837 (diff) |
Merge 5.11-rc3 into char-misc-next
We need the char/misc fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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; |