From owner-svn-src-all@FreeBSD.ORG Thu Jan 26 19:18:11 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 250E61065675; Thu, 26 Jan 2012 19:18:11 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1339E8FC12; Thu, 26 Jan 2012 19:18:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0QJIAJn002290; Thu, 26 Jan 2012 19:18:10 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0QJIAkY002288; Thu, 26 Jan 2012 19:18:10 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201201261918.q0QJIAkY002288@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Thu, 26 Jan 2012 19:18:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230596 - stable/8/sys/dev/acpica X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jan 2012 19:18:11 -0000 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;