Page MenuHomeFreeBSD
Paste P636

acpi_battery div by zero quick & dirty patch
ActivePublic

Authored by jeffpc_josefsipek.net on Apr 16 2024, 1:24 PM.
Tags
None
Referenced Files
F81449435: acpi_battery div by zero quick & dirty patch
Apr 16 2024, 1:24 PM
Subscribers
None
diff --git a/sys/dev/acpica/acpi_battery.c b/sys/dev/acpica/acpi_battery.c
--- a/sys/dev/acpica/acpi_battery.c
+++ b/sys/dev/acpica/acpi_battery.c
@@ -266,7 +266,7 @@ acpi_battery_get_battinfo(device_t dev,
*/
if (valid_units > 0) {
if (dev == NULL) {
- battinfo->cap = (total_cap * 100) / total_lfcap;
+ battinfo->cap = total_lfcap ? ((total_cap * 100) / total_lfcap) : 0;
battinfo->min = total_min;
battinfo->state = batt_stat;
battinfo->rate = valid_rate;