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,14 @@ */ if (valid_units > 0) { if (dev == NULL) { - battinfo->cap = (total_cap * 100) / total_lfcap; + /* + * Avoid division by zero if none of the batteries had valid + * capacity info. + */ + if (total_lfcap > 0) + battinfo->cap = (total_cap * 100) / total_lfcap; + else + battinfo->cap = 0; battinfo->min = total_min; battinfo->state = batt_stat; battinfo->rate = valid_rate;