Package: upower
Version: 1.90.3-1
Severity: important
Tags: patch upstream

Dear Maintainer,

On systems with broken battery controllers, ACPI may report an invalid battery
capacity value, specifically `-NaN`. This causes `upowerd` to crash repeatedly
due to an invalid gdouble being passed to `g_object_set`.

This leads to system instability or continuous reboots due to repeated crashes
of systemd-managed services.

The following patch adds a basic sanity check to clamp invalid values to 0.0.

--- PATCH START ---
--- upower-1.90.3.orig/src/linux/up-device-supply.c
+++ upower-1.90.3/src/linux/up-device-supply.c
@@ -313,6 +313,11 @@ up_device_supply_refresh_device (UpDevic
        if (percentage == 100.0)
                state = UP_DEVICE_STATE_FULLY_CHARGED;
 
+       if (!isfinite(percentage) || percentage < 0.0 || percentage > 100.0) {
+               g_warning("Invalid percentage value: %f, setting to 0.0", 
percentage);
+               percentage = 0.0;
+       }
+
        g_object_set (device,
                      "percentage", percentage,
                      "battery-level", level,
--- PATCH END ---

Tested on affected system; no crash occurs after patch is applied.

Regards,  
Renkas Mykhailo

Reply via email to