Commit 2ff90100 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'hwmon-for-v5.11-rc3' of...

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
parents f408126b 84e26155
.. SPDX-License-Identifier: GPL-2.0-or-later .. SPDX-License-Identifier: GPL-2.0-or-later
Kernel driver sbtsi_temp Kernel driver sbtsi_temp
================== ========================
Supported hardware: Supported hardware:
......
...@@ -222,7 +222,7 @@ static int amd_create_sensor(struct device *dev, ...@@ -222,7 +222,7 @@ static int amd_create_sensor(struct device *dev,
*/ */
cpus = num_present_cpus() / num_siblings; cpus = num_present_cpus() / num_siblings;
s_config = devm_kcalloc(dev, cpus + sockets, s_config = devm_kcalloc(dev, cpus + sockets + 1,
sizeof(u32), GFP_KERNEL); sizeof(u32), GFP_KERNEL);
if (!s_config) if (!s_config)
return -ENOMEM; return -ENOMEM;
...@@ -254,6 +254,7 @@ static int amd_create_sensor(struct device *dev, ...@@ -254,6 +254,7 @@ static int amd_create_sensor(struct device *dev,
scnprintf(label_l[i], 10, "Esocket%u", (i - cpus)); scnprintf(label_l[i], 10, "Esocket%u", (i - cpus));
} }
s_config[i] = 0;
return 0; return 0;
} }
......
...@@ -334,8 +334,18 @@ static int pwm_fan_probe(struct platform_device *pdev) ...@@ -334,8 +334,18 @@ static int pwm_fan_probe(struct platform_device *pdev)
ctx->pwm_value = MAX_PWM; ctx->pwm_value = MAX_PWM;
/* Set duty cycle to maximum allowed and enable PWM output */
pwm_init_state(ctx->pwm, &state); 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.duty_cycle = ctx->pwm->args.period - 1;
state.enabled = true; state.enabled = true;
......
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