Skip to contentSkip to conversation

ACPI: Fixes device power states array overflow

PATCH Superseded Lin Ming 2 participants 3 messages May 30, 2011 – Jun 1, 2011

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lin Ming

author
#0 lore raw

PATCH 1/1 ACPI: Fixes device power states array overflow

Commit 28c2103 added new state ACPI_STATE_D3_COLD, so the device power states array must be expanded by one also.

---
 include/acpi/acpi_bus.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/acpi/acpi_bus.h +1 -1
index 3a10ef5..ff246e8 100644
@@ -210,7 +210,7 @@ struct acpi_device_power_state {
 struct acpi_device_power {
 	int state;		/* Current state */
 	struct acpi_device_power_flags flags;
-	struct acpi_device_power_state states[4];	/* Power states (D0-D3) */
+	struct acpi_device_power_state states[5];	/* Power states (D0-D3Cold) */
 };
 
 /* Performance Management */
Signature · 1 line
1.7.2.3
#1 lore raw

Hi Lin,

Quoted 14 lines · Lin Ming

Commit 28c2103 added new state ACPI_STATE_D3_COLD, so the device power states array must be expanded by one also.

---
 include/acpi/acpi_bus.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/acpi/acpi_bus.h +0 -0
index 3a10ef5..ff246e8 100644

include/acpi/acpi_bus.h struct acpi_device_power_state { · line 213

Quoted 5 lines
include/acpi/acpi_bus.h +1 -1
@@ -210,7 +210,7 @@ struct acpi_device_power_state {
 struct acpi_device_power {
 	int state;		/* Current state */
 	struct acpi_device_power_flags flags;
-	struct acpi_device_power_state states[4];	/* Power states (D0-D3) */
+	struct acpi_device_power_state states[5];	/* Power states (D0-D3Cold) 

*/

Wouldn't it be better to use some constant, so that the same problem would not appear again in future - something like ACPI_D_STATE_COUNT or (maybe better) ACPI_D_STATES_MAX+1 instead of magic number 5?

Cheers,
Oldřich.

include/acpi/acpi_bus.h struct acpi_device_power_state { · line 216

Quoted 3 lines
include/acpi/acpi_bus.h +0 -0
 };
 
 /* Performance Management */

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw
Quoted 24 lines · 在 2011-06-01三的 05:09 +0800,Oldřich Jedlička写道:

Hi Lin,

Quoted 14 lines · Lin Ming

Commit 28c2103 added new state ACPI_STATE_D3_COLD, so the device power states array must be expanded by one also.

---
 include/acpi/acpi_bus.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/acpi/acpi_bus.h +0 -0
index 3a10ef5..ff246e8 100644

include/acpi/acpi_bus.h struct acpi_device_power_state { · line 213

Quoted 5 lines
include/acpi/acpi_bus.h +1 -1
@@ -210,7 +210,7 @@ struct acpi_device_power_state {
 struct acpi_device_power {
 	int state;		/* Current state */
 	struct acpi_device_power_flags flags;
-	struct acpi_device_power_state states[4];	/* Power states (D0-D3) */
+	struct acpi_device_power_state states[5];	/* Power states (D0-D3Cold) 

*/

Quoted 3 lines

Wouldn't it be better to use some constant, so that the same problem would not appear again in future - something like ACPI_D_STATE_COUNT or (maybe better) ACPI_D_STATES_MAX+1 instead of magic number 5?

Nice catch, I have updated the patch.

Thanks.

Quoted 8 lines

Cheers,
Oldřich.

Quoted 3 lines
include/acpi/acpi_bus.h +0 -0
 };
 
 /* Performance Management */

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html