From: Roland Dreier <roland@digitalvampire.org>
To: Len Brown <len.brown@intel.com>
Cc: linux-acpi@vger.kernel.org, Alexey Starikovskiy <astarikovskiy@suse.de>
Subject: ACPI: Always return valid 'status' from acpi_battery_get_property()
Date: Wed, 07 Nov 2007 15:09:09 -0800 [thread overview]
Message-ID: <87640d1wmi.fsf@shaolin.home.digitalvampire.org> (raw)
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>
---
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index c2ce0ad..cbb27b4 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -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);
next reply other threads:[~2007-11-07 23:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-07 23:09 Roland Dreier [this message]
2007-11-08 8:29 ` ACPI: Always return valid 'status' from acpi_battery_get_property() Alexey Starikovskiy
2007-11-08 14:42 ` Henrique de Moraes Holschuh
2007-11-19 12:46 ` Alexey Starikovskiy
2007-11-19 18:36 ` Henrique de Moraes Holschuh
2007-11-19 18:41 ` Alexey Starikovskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87640d1wmi.fsf@shaolin.home.digitalvampire.org \
--to=roland@digitalvampire.org \
--cc=astarikovskiy@suse.de \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox