]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwmon: (acpi_power_meter) Fix 4.29 MW bug
authorArmin Wolf <W_Armin@gmx.de>
Fri, 24 Nov 2023 18:27:47 +0000 (19:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Dec 2023 17:36:39 +0000 (18:36 +0100)
commit9deab0c35ea42f1eb421f2f78c9e60b15fac24a6
treecf891018664109b5db3f848dcc4e0c4078169409
parent8ef49679a2f1f7bf54c8b2cdbb586deab25f9030
hwmon: (acpi_power_meter) Fix 4.29 MW bug

[ Upstream commit 1fefca6c57fb928d2131ff365270cbf863d89c88 ]

The ACPI specification says:

"If an error occurs while obtaining the meter reading or if the value
is not available then an Integer with all bits set is returned"

Since the "integer" is 32 bits in case of the ACPI power meter,
userspace will get a power reading of 2^32 * 1000 miliwatts (~4.29 MW)
in case of such an error. This was discovered due to a lm_sensors
bugreport (https://github.com/lm-sensors/lm-sensors/issues/460).
Fix this by returning -ENODATA instead.

Tested-by: <urbinek@gmail.com>
Fixes: de584afa5e18 ("hwmon driver for ACPI 4.0 power meters")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20231124182747.13956-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/acpi_power_meter.c