Skip to content

Commit 2ff9010

Browse files
committed
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
2 parents f408126 + 84e2615 commit 2ff9010

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Documentation/hwmon/sbtsi_temp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. SPDX-License-Identifier: GPL-2.0-or-later
22
33
Kernel driver sbtsi_temp
4-
==================
4+
========================
55

66
Supported hardware:
77

drivers/hwmon/amd_energy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static int amd_create_sensor(struct device *dev,
222222
*/
223223
cpus = num_present_cpus() / num_siblings;
224224

225-
s_config = devm_kcalloc(dev, cpus + sockets,
225+
s_config = devm_kcalloc(dev, cpus + sockets + 1,
226226
sizeof(u32), GFP_KERNEL);
227227
if (!s_config)
228228
return -ENOMEM;
@@ -254,6 +254,7 @@ static int amd_create_sensor(struct device *dev,
254254
scnprintf(label_l[i], 10, "Esocket%u", (i - cpus));
255255
}
256256

257+
s_config[i] = 0;
257258
return 0;
258259
}
259260

drivers/hwmon/pwm-fan.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,18 @@ static int pwm_fan_probe(struct platform_device *pdev)
334334

335335
ctx->pwm_value = MAX_PWM;
336336

337-
/* Set duty cycle to maximum allowed and enable PWM output */
338337
pwm_init_state(ctx->pwm, &state);
338+
/*
339+
* __set_pwm assumes that MAX_PWM * (period - 1) fits into an unsigned
340+
* long. Check this here to prevent the fan running at a too low
341+
* frequency.
342+
*/
343+
if (state.period > ULONG_MAX / MAX_PWM + 1) {
344+
dev_err(dev, "Configured period too big\n");
345+
return -EINVAL;
346+
}
347+
348+
/* Set duty cycle to maximum allowed and enable PWM output */
339349
state.duty_cycle = ctx->pwm->args.period - 1;
340350
state.enabled = true;
341351

0 commit comments

Comments
 (0)