public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix segfault when printing battery status
@ 2007-11-18 19:49 Rolf Eike Beer
  2007-11-19  9:45 ` Alexey Starikovskiy
  0 siblings, 1 reply; 5+ messages in thread
From: Rolf Eike Beer @ 2007-11-18 19:49 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, astarikovskiy, kernel list

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]

cat /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:19/PNP0C0A:00/power_supply/BAT1/status

This leads to a stacktrace as acpi_battery_get_property() returns 0 for a 
case where it does not set val->intval. These value is used as an array 
index in drivers/power/power_supply_sysfs.c::power_supply_show_property(). 
I had a situation where the value was 4096 which caused a problem as the 
array only has 5 entries.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 192c244..2e8e790 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -153,6 +153,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);

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix segfault when printing battery status
  2007-11-18 19:49 [PATCH] Fix segfault when printing battery status Rolf Eike Beer
@ 2007-11-19  9:45 ` Alexey Starikovskiy
  2007-11-19 10:29   ` Rolf Eike Beer
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Starikovskiy @ 2007-11-19  9:45 UTC (permalink / raw)
  To: Rolf Eike Beer; +Cc: lenb, linux-acpi, astarikovskiy, kernel list


Rolf Eike Beer wrote:
> cat /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:19/PNP0C0A:00/power_supply/BAT1/status
>
> This leads to a stacktrace as acpi_battery_get_property() returns 0 for a 
> case where it does not set val->intval. These value is used as an array 
> index in drivers/power/power_supply_sysfs.c::power_supply_show_property(). 
> I had a situation where the value was 4096 which caused a problem as the 
> array only has 5 entries.
>
> Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
>   
Rolf, thanks for remainding.
Acked again,
Alex.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix segfault when printing battery status
  2007-11-19  9:45 ` Alexey Starikovskiy
@ 2007-11-19 10:29   ` Rolf Eike Beer
  2007-11-19 11:09     ` Alexey Starikovskiy
  0 siblings, 1 reply; 5+ messages in thread
From: Rolf Eike Beer @ 2007-11-19 10:29 UTC (permalink / raw)
  To: Alexey Starikovskiy; +Cc: lenb, linux-acpi, astarikovskiy, kernel list

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

Alexey Starikovskiy wrote:
> Rolf Eike Beer wrote:
> > cat
> > /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:19/PNP0C0A:00/power_
> >supply/BAT1/status
> >
> > This leads to a stacktrace as acpi_battery_get_property() returns 0 for a
> > case where it does not set val->intval. These value is used as an array
> > index in
> > drivers/power/power_supply_sysfs.c::power_supply_show_property(). I had a
> > situation where the value was 4096 which caused a problem as the array
> > only has 5 entries.
> >
> > Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
>
> Rolf, thanks for remainding.

Huh? This one is unrelated to the problem I reported two weeks ago...

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix segfault when printing battery status
  2007-11-19 10:29   ` Rolf Eike Beer
@ 2007-11-19 11:09     ` Alexey Starikovskiy
  2007-11-26 22:25       ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Starikovskiy @ 2007-11-19 11:09 UTC (permalink / raw)
  To: Rolf Eike Beer; +Cc: lenb, linux-acpi, astarikovskiy, kernel list

Rolf Eike Beer wrote:
> Alexey Starikovskiy wrote:
>   
>> Rolf Eike Beer wrote:
>>     
>>> cat
>>> /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:19/PNP0C0A:00/power_
>>> supply/BAT1/status
>>>
>>> This leads to a stacktrace as acpi_battery_get_property() returns 0 for a
>>> case where it does not set val->intval. These value is used as an array
>>> index in
>>> drivers/power/power_supply_sysfs.c::power_supply_show_property(). I had a
>>> situation where the value was 4096 which caused a problem as the array
>>> only has 5 entries.
>>>
>>> Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
>>>       
>> Rolf, thanks for remainding.
>>     
>
> Huh? This one is unrelated to the problem I reported two weeks ago...
>
> Eike
>   
You are second to send the same patch, first one I already acked.
But it seems that Len did not pick it up yet.
Look for "ACPI: Always return valid 'status' from 
acpi_battery_get_property()"
if interested...

Regards,
Alex.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix segfault when printing battery status
  2007-11-19 11:09     ` Alexey Starikovskiy
@ 2007-11-26 22:25       ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2007-11-26 22:25 UTC (permalink / raw)
  To: Alexey Starikovskiy
  Cc: eike-kernel, lenb, linux-acpi, astarikovskiy, linux-kernel

On Mon, 19 Nov 2007 14:09:51 +0300
Alexey Starikovskiy <aystarik@gmail.com> wrote:

> Rolf Eike Beer wrote:
> > Alexey Starikovskiy wrote:
> >   
> >> Rolf Eike Beer wrote:
> >>     
> >>> cat
> >>> /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:19/PNP0C0A:00/power_
> >>> supply/BAT1/status
> >>>
> >>> This leads to a stacktrace as acpi_battery_get_property() returns 0 for a
> >>> case where it does not set val->intval. These value is used as an array
> >>> index in
> >>> drivers/power/power_supply_sysfs.c::power_supply_show_property(). I had a
> >>> situation where the value was 4096 which caused a problem as the array
> >>> only has 5 entries.
> >>>
> >>> Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
> >>>       
> >> Rolf, thanks for remainding.
> >>     
> >
> > Huh? This one is unrelated to the problem I reported two weeks ago...
> >
> > Eike
> >   
> You are second to send the same patch, first one I already acked.
> But it seems that Len did not pick it up yet.
> Look for "ACPI: Always return valid 'status' from 
> acpi_battery_get_property()"
> if interested...
> 

This fix is in Len's tree and was in his 2.6.24-rc3 pull request to
Linus.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-11-26 22:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-18 19:49 [PATCH] Fix segfault when printing battery status Rolf Eike Beer
2007-11-19  9:45 ` Alexey Starikovskiy
2007-11-19 10:29   ` Rolf Eike Beer
2007-11-19 11:09     ` Alexey Starikovskiy
2007-11-26 22:25       ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox