Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2012 19:18:10 +0000 (UTC)
From:      Jean-Sebastien Pedron <dumbbell@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r230596 - stable/8/sys/dev/acpica
Message-ID:  <201201261918.q0QJIAkY002288@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201261918.q0QJIAkY002288>