linux/drivers/hwmon/pmbus
Guenter Roeck 0dabe8a56f hwmon: (pmbus/lm25066) Fix PMBus coefficient calculations
In lm25066_probe(), the PMBus coefficients for current and power are
scaled based on the shunt resistor value. The calculation evaluates the
multiplication using 32-bit arithmetic because info->m is an int and
shunt is a u32:

static int lm25066_probe(struct i2c_client *client) {
    ...
    info->m[PSC_CURRENT_IN] = info->m[PSC_CURRENT_IN] * shunt / 1000;
    info->m[PSC_POWER] = info->m[PSC_POWER] * shunt / 1000;
    ...
}

For large coefficients like 26882 (LM25056) or 15076 (LM5066i), a device
tree shunt-resistor-micro-ohms value exceeding approximately 159,000
(159 mOhm, which is physically valid for low-current applications) causes
the intermediate product to exceed UINT_MAX (4,294,967,295). This results
in a silent wraparound before the division by 1000.

Furthermore, if the wrapped value has the most significant bit set,
converting it back to the signed int info->m results in negative
coefficients. This logic error leads to drastically corrupted current and
power readings, which can cause erratic thermal or power management
behavior in the system.

Fix the problem by using 64-bit operations for the multiply/divide
operations. This can still overflow, but only for unreasonably large
shunt resistor values.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Fixes: 94ee5fcc24 ("hwmon: (pmbus/lm25066) Support configurable sense resistor values")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
History 2026-08-04 15:31:48 -07:00
..
acbel-fsg032.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
adm1266.c hwmon: (pmbus/adm1266) add rtc debugfs entry 2026-06-09 08:23:09 -07:00
adm1275.c hwmon: adm1275: Detect coefficient overflow 2026-06-29 13:46:10 -07:00
adp1050.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
aps-379.c hwmon: Drop unused i2c driver_data 2026-06-09 08:22:59 -07:00
bel-pfe.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
bpa-rs600.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
crps.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
d1u74t.c hwmon: (pmbus/d1u74t) Add Murata D1U74T PSU driver 2026-06-09 08:23:00 -07:00
delta-ahe50dc-fan.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
dps920ab.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
e50sn12051.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
fsp-3y.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
hac300s.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ibm-cffps.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ina233.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
inspur-ipsps.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ir35221.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ir36021.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ir38064.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
irps5401.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
isl68137.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
Kconfig hwmon: (pmbus/xdp720) Add support for efuse xdp730 2026-06-09 08:23:18 -07:00
lm25066.c hwmon: (pmbus/lm25066) Fix PMBus coefficient calculations 2026-08-04 15:31:48 -07:00
lt3074.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
lt7182s.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ltc2978.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ltc3815.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ltc4286.c hwmon: (ltc4286) Add missing MODULE_IMPORT_NS("PMBUS") 2026-03-29 19:04:16 -07:00
lx1308.c hwmon: (pmbus/lx1308) Add support for LX1308 2026-06-09 08:22:52 -07:00
Makefile hwmon: (pmbus/max20860a) Add driver for Analog Devices MAX20860A 2026-06-09 08:23:18 -07:00
max8688.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
max15301.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
max16064.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
max16601.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
max17616.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
max20730.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
max20751.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
max20830.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
max20860a.c hwmon: (pmbus/max20860a) Add driver for Analog Devices MAX20860A 2026-06-09 08:23:18 -07:00
max31785.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
max34440.c hwmon: (pmbus/max34440) block unsupported VIN and IIN limit registers 2026-07-19 07:15:00 -07:00
mp2856.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp2869.c hwmon: (pmbus/mp2869) Drop unjustified __maybe_unused 2026-06-09 08:22:59 -07:00
mp2888.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp2891.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp2925.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp2975.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
mp2985.c hwmon: add MP2985 driver 2026-05-24 13:54:01 -07:00
mp2993.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp5023.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
mp5920.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp5926.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp5990.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp9941.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp9945.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mp29502.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mpq7932.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
mpq8785.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
pim4328.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
pli1209bc.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
pm6764tr.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
pmbus.c hwmon: (pmbus) Add support for Flex BMR316, BMR321, BMR350 and BMR351 2026-06-09 08:23:17 -07:00
pmbus.h hwmon: (pmbus) Add support for guarded PMBus lock 2026-03-30 19:45:06 -07:00
pmbus_core.c hwmon: (pmbus) Fix type confusion in notification logic 2026-08-03 12:54:16 -07:00
pxe1610.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
q54sj108a2.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
stef48h28.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
stpddc60.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
tda38640.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
tps546d24.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
tps25990.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
tps40422.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
tps53679.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ucd9000.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
ucd9200.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
xdp710.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
xdp720.c hwmon: (pmbus/xdp720) Fix driver issues xdp720/730 2026-06-09 08:23:21 -07:00
xdpe1a2g7b.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
xdpe152c4.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
xdpe12284.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00
zl6100.c hwmon: Use named initializers for arrays of i2c_device_data 2026-06-09 08:22:59 -07:00