Commit 5f226169 authored by Armin Wolf's avatar Armin Wolf Committed by Zheng Zengkai
Browse files

hwmon: (acpi_power_meter) Fix 4.29 MW bug

stable inclusion
from stable-v6.6.7
commit 8ebf05908f0e8ab5d2c50555ed059fa239b31072
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8SSQ4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8ebf05908f0e8ab5d2c50555ed059fa239b31072

--------------------------------

[ 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: default avatar <urbinek@gmail.com>
Fixes: de584afa ("hwmon driver for ACPI 4.0 power meters")
Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20231124182747.13956-1-W_Armin@gmx.de


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent c1b97d57
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment