diff mbox

ACPI: Fixes device power states array overflow

Message ID 1306762961.2244.13.camel@localhost (mailing list archive)
State New, archived
Headers show

Commit Message

Lin Ming May 30, 2011, 1:42 p.m. UTC
Commit 28c2103 added new state ACPI_STATE_D3_COLD, so the device power
states array must be expanded by one also.

Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
 include/acpi/acpi_bus.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Oldřich Jedlička May 31, 2011, 9:09 p.m. UTC | #1
Hi Lin,

On Monday 30 May 2011 at 15:42:41, Lin Ming wrote:
> Commit 28c2103 added new state ACPI_STATE_D3_COLD, so the device power
> states array must be expanded by one also.
> 
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Lin Ming <ming.m.lin@intel.com>
> ---
>  include/acpi/acpi_bus.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index 3a10ef5..ff246e8 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -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.


>  };
> 
>  /* Performance Management */
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lin Ming June 1, 2011, 3:55 p.m. UTC | #2
? 2011-06-01?? 05:09 +0800?Old?ich Jedli?ka???
> Hi Lin,
> 
> On Monday 30 May 2011 at 15:42:41, Lin Ming wrote:
> > Commit 28c2103 added new state ACPI_STATE_D3_COLD, so the device power
> > states array must be expanded by one also.
> > 
> > Reported-by: Dan Carpenter <error27@gmail.com>
> > Signed-off-by: Lin Ming <ming.m.lin@intel.com>
> > ---
> >  include/acpi/acpi_bus.h |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> > index 3a10ef5..ff246e8 100644
> > --- a/include/acpi/acpi_bus.h
> > +++ b/include/acpi/acpi_bus.h
> > @@ -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?

Nice catch, I have updated the patch.

Thanks.

> 
> Cheers,
> Old?ich.
> 
> 
> >  };
> > 
> >  /* Performance Management */


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

Patch

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 3a10ef5..ff246e8 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -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 */