svn commit: r230596 - stable/8/sys/dev/acpica

Jean-Sebastien Pedron dumbbell at FreeBSD.org
Thu Jan 26 19:18:11 UTC 2012


Author: dumbbell
Date: Thu Jan 26 19:18:10 2012
New Revision: 230596
URL: http://svn.freebsd.org/changeset/base/230596

Log:
  MFC r227992:
  
  Prevent a division by zero with some broken batteries
  
  This problem was seen on a laptop with a dead battery.

Modified:
  stable/8/sys/dev/acpica/acpi_battery.c
Directory Properties:
  stable/8/sys/   (props changed)

Modified: stable/8/sys/dev/acpica/acpi_battery.c
==============================================================================
--- stable/8/sys/dev/acpica/acpi_battery.c	Thu Jan 26 19:15:13 2012	(r230595)
+++ stable/8/sys/dev/acpica/acpi_battery.c	Thu Jan 26 19:18:10 2012	(r230596)
@@ -205,6 +205,14 @@ acpi_battery_get_battinfo(device_t dev, 
 	    bif->lfcap = (bif->lfcap * bif->dvol) / 1000;
 	}
 
+	/*
+	 * The calculation above may set bif->lfcap to zero. This was
+	 * seen on a laptop with a broken battery. The result of the
+	 * division was rounded to zero.
+	 */
+	if (!acpi_battery_bif_valid(bif))
+	    continue;
+
 	/* Calculate percent capacity remaining. */
 	bi[i].cap = (100 * bst[i].cap) / bif->lfcap;
 


More information about the svn-src-all mailing list