diff mbox

[4/4] platform/x86: wmi: Fix check for method instance number

Message ID 1502523858-25716-5-git-send-email-pali.rohar@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Andy Shevchenko
Headers show

Commit Message

Pali Rohár Aug. 12, 2017, 7:44 a.m. UTC
instance_count defines number of instances of data block and instance
itself is indexed from zero, which means first instance has number 0.
Therefore check for invalid instance should be non-strict inequality.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 drivers/platform/x86/wmi.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Darren Hart Aug. 17, 2017, 3:24 p.m. UTC | #1
On Sat, Aug 12, 2017 at 09:44:18AM +0200, Pali Rohár wrote:
> instance_count defines number of instances of data block and instance
> itself is indexed from zero, which means first instance has number 0.
> Therefore check for invalid instance should be non-strict inequality.
> 
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>

This is correct per the WMI specification. Pali, now that Andy has
applied 1-3 of this series, is that all the required driver updates?

Reviewed-by: Darren Hart (VMware) <dvhart@infradead.org>


> ---
>  drivers/platform/x86/wmi.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index e32ba57..0765b17 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -218,7 +218,7 @@ acpi_status wmi_evaluate_method(const char *guid_string, u8 instance,
>  	if (!(block->flags & ACPI_WMI_METHOD))
>  		return AE_BAD_DATA;
>  
> -	if (block->instance_count < instance)
> +	if (block->instance_count <= instance)
>  		return AE_BAD_PARAMETER;
>  
>  	input.count = 2;
> @@ -265,7 +265,7 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
>  	block = &wblock->gblock;
>  	handle = wblock->acpi_device->handle;
>  
> -	if (block->instance_count < instance)
> +	if (block->instance_count <= instance)
>  		return AE_BAD_PARAMETER;
>  
>  	/* Check GUID is a data block */
> @@ -392,7 +392,7 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance,
>  	block = &wblock->gblock;
>  	handle = wblock->acpi_device->handle;
>  
> -	if (block->instance_count < instance)
> +	if (block->instance_count <= instance)
>  		return AE_BAD_PARAMETER;
>  
>  	/* Check GUID is a data block */
> -- 
> 1.7.9.5
> 
>
Pali Rohár Aug. 17, 2017, 9:13 p.m. UTC | #2
On Thursday 17 August 2017 08:24:31 Darren Hart wrote:
> On Sat, Aug 12, 2017 at 09:44:18AM +0200, Pali Rohár wrote:
> > instance_count defines number of instances of data block and instance
> > itself is indexed from zero, which means first instance has number 0.
> > Therefore check for invalid instance should be non-strict inequality.
> > 
> > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> 
> This is correct per the WMI specification. Pali, now that Andy has
> applied 1-3 of this series, is that all the required driver updates?

Hmmm... I have not understood your question.

I checked that all drivers which uses instance id 1 have comment
explaining why is id 1 used.

Problematic drivers without comment have either patch to use instance id
0 in this series or somebody else already supplied patch which is part
of linus tree.

> Reviewed-by: Darren Hart (VMware) <dvhart@infradead.org>
> 
> 
> > ---
> >  drivers/platform/x86/wmi.c |    6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> > index e32ba57..0765b17 100644
> > --- a/drivers/platform/x86/wmi.c
> > +++ b/drivers/platform/x86/wmi.c
> > @@ -218,7 +218,7 @@ acpi_status wmi_evaluate_method(const char *guid_string, u8 instance,
> >  	if (!(block->flags & ACPI_WMI_METHOD))
> >  		return AE_BAD_DATA;
> >  
> > -	if (block->instance_count < instance)
> > +	if (block->instance_count <= instance)
> >  		return AE_BAD_PARAMETER;
> >  
> >  	input.count = 2;
> > @@ -265,7 +265,7 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
> >  	block = &wblock->gblock;
> >  	handle = wblock->acpi_device->handle;
> >  
> > -	if (block->instance_count < instance)
> > +	if (block->instance_count <= instance)
> >  		return AE_BAD_PARAMETER;
> >  
> >  	/* Check GUID is a data block */
> > @@ -392,7 +392,7 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance,
> >  	block = &wblock->gblock;
> >  	handle = wblock->acpi_device->handle;
> >  
> > -	if (block->instance_count < instance)
> > +	if (block->instance_count <= instance)
> >  		return AE_BAD_PARAMETER;
> >  
> >  	/* Check GUID is a data block */
> > -- 
> > 1.7.9.5
> > 
> > 
>
Darren Hart Aug. 17, 2017, 9:36 p.m. UTC | #3
On Thu, Aug 17, 2017 at 11:13:19PM +0200, Pali Rohár wrote:
> On Thursday 17 August 2017 08:24:31 Darren Hart wrote:
> > On Sat, Aug 12, 2017 at 09:44:18AM +0200, Pali Rohár wrote:
> > > instance_count defines number of instances of data block and instance
> > > itself is indexed from zero, which means first instance has number 0.
> > > Therefore check for invalid instance should be non-strict inequality.
> > > 
> > > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> > 
> > This is correct per the WMI specification. Pali, now that Andy has
> > applied 1-3 of this series, is that all the required driver updates?
> 
> Hmmm... I have not understood your question.
> 
> I checked that all drivers which uses instance id 1 have comment
> explaining why is id 1 used.
> 
> Problematic drivers without comment have either patch to use instance id
> 0 in this series or somebody else already supplied patch which is part
> of linus tree.

Perfect, that is what I was looking for. Thanks Pali!

> 
> > Reviewed-by: Darren Hart (VMware) <dvhart@infradead.org>
Andy Shevchenko Aug. 18, 2017, 12:20 p.m. UTC | #4
On Thu, Aug 17, 2017 at 6:24 PM, Darren Hart <dvhart@infradead.org> wrote:
> On Sat, Aug 12, 2017 at 09:44:18AM +0200, Pali Rohár wrote:
>> instance_count defines number of instances of data block and instance
>> itself is indexed from zero, which means first instance has number 0.
>> Therefore check for invalid instance should be non-strict inequality.
>>
>> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
>
> This is correct per the WMI specification. Pali, now that Andy has
> applied 1-3 of this series, is that all the required driver updates?
>
> Reviewed-by: Darren Hart (VMware) <dvhart@infradead.org>

Pushed to testing, thanks!

>
>
>> ---
>>  drivers/platform/x86/wmi.c |    6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
>> index e32ba57..0765b17 100644
>> --- a/drivers/platform/x86/wmi.c
>> +++ b/drivers/platform/x86/wmi.c
>> @@ -218,7 +218,7 @@ acpi_status wmi_evaluate_method(const char *guid_string, u8 instance,
>>       if (!(block->flags & ACPI_WMI_METHOD))
>>               return AE_BAD_DATA;
>>
>> -     if (block->instance_count < instance)
>> +     if (block->instance_count <= instance)
>>               return AE_BAD_PARAMETER;
>>
>>       input.count = 2;
>> @@ -265,7 +265,7 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
>>       block = &wblock->gblock;
>>       handle = wblock->acpi_device->handle;
>>
>> -     if (block->instance_count < instance)
>> +     if (block->instance_count <= instance)
>>               return AE_BAD_PARAMETER;
>>
>>       /* Check GUID is a data block */
>> @@ -392,7 +392,7 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance,
>>       block = &wblock->gblock;
>>       handle = wblock->acpi_device->handle;
>>
>> -     if (block->instance_count < instance)
>> +     if (block->instance_count <= instance)
>>               return AE_BAD_PARAMETER;
>>
>>       /* Check GUID is a data block */
>> --
>> 1.7.9.5
>>
>>
>
> --
> Darren Hart
> VMware Open Source Technology Center
diff mbox

Patch

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index e32ba57..0765b17 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -218,7 +218,7 @@  acpi_status wmi_evaluate_method(const char *guid_string, u8 instance,
 	if (!(block->flags & ACPI_WMI_METHOD))
 		return AE_BAD_DATA;
 
-	if (block->instance_count < instance)
+	if (block->instance_count <= instance)
 		return AE_BAD_PARAMETER;
 
 	input.count = 2;
@@ -265,7 +265,7 @@  static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
 	block = &wblock->gblock;
 	handle = wblock->acpi_device->handle;
 
-	if (block->instance_count < instance)
+	if (block->instance_count <= instance)
 		return AE_BAD_PARAMETER;
 
 	/* Check GUID is a data block */
@@ -392,7 +392,7 @@  acpi_status wmi_set_block(const char *guid_string, u8 instance,
 	block = &wblock->gblock;
 	handle = wblock->acpi_device->handle;
 
-	if (block->instance_count < instance)
+	if (block->instance_count <= instance)
 		return AE_BAD_PARAMETER;
 
 	/* Check GUID is a data block */