Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153220290
D44818.id137203.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
607 B
Referenced Files
None
Subscribers
None
D44818.id137203.diff
View Options
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;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 20, 9:32 PM (8 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31866179
Default Alt Text
D44818.id137203.diff (607 B)
Attached To
Mode
D44818: acpi_battery: avoid divide-by-zero when no devices have capacity info
Attached
Detach File
Event Timeline
Log In to Comment