Patch "hwmon: (acpi_power_meter) Fix 4.29 MW bug" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    hwmon: (acpi_power_meter) Fix 4.29 MW bug

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     hwmon-acpi_power_meter-fix-4.29-mw-bug.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b040f62614e372766ae9147b1ee7d984396f7756
Author: Armin Wolf <W_Armin@xxxxxx>
Date:   Fri Nov 24 19:27:47 2023 +0100

    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@xxxxxxxxx>
    Fixes: de584afa5e18 ("hwmon driver for ACPI 4.0 power meters")
    Signed-off-by: Armin Wolf <W_Armin@xxxxxx>
    Link: https://lore.kernel.org/r/20231124182747.13956-1-W_Armin@xxxxxx
    Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index fa28d447f0dfb..b772c076a5aed 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -31,6 +31,7 @@
 #define POWER_METER_CAN_NOTIFY	(1 << 3)
 #define POWER_METER_IS_BATTERY	(1 << 8)
 #define UNKNOWN_HYSTERESIS	0xFFFFFFFF
+#define UNKNOWN_POWER		0xFFFFFFFF
 
 #define METER_NOTIFY_CONFIG	0x80
 #define METER_NOTIFY_TRIP	0x81
@@ -348,6 +349,9 @@ static ssize_t show_power(struct device *dev,
 	update_meter(resource);
 	mutex_unlock(&resource->lock);
 
+	if (resource->power == UNKNOWN_POWER)
+		return -ENODATA;
+
 	return sprintf(buf, "%llu\n", resource->power * 1000);
 }
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux