Skip to content

Commit

Permalink
ACPI: Always return valid 'status' from acpi_battery_get_property()
Browse files Browse the repository at this point in the history
If a battery is at a critical charge level and not being charged or
discharged, then the ACPI _BST method will return a state of 4, and
the current acpi_battery_get_property() code will not set any property
value for POWER_SUPPLY_PROP_STATUS.  This will cause an oops in
power_supply_show_property() when it reads off the end of the
status_text array.  This actually was causing a 100% reproducible
crash on boot on my laptop with two batteries, when one battery was
completely drained and the laptop was not plugged in.

Fix this by making sure acpi_battery_get_property() returns
POWER_SUPPLY_STATUS_UNKNOWN for any battery state it doesn't already
handle explicitly.  There doesn't seem to be any status enum value
defined that makes more sense than 'unknown' for a battery at a
critical charge level.

Signed-off-by: Roland Dreier <roland@digitalvampire.org>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <lenb@t61.(none)>
  • Loading branch information
Roland Dreier authored and Len Brown committed Nov 8, 2007
1 parent dbeeb81 commit 4c41d3a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else if (battery->state == 0)
val->intval = POWER_SUPPLY_STATUS_FULL;
else
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
break;
case POWER_SUPPLY_PROP_PRESENT:
val->intval = acpi_battery_present(battery);
Expand Down

0 comments on commit 4c41d3a

Please sign in to comment.