LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] intel_menlo: max_state is unsigned, invalid test
@ 2008-10-29 21:06 roel kluin
  2008-11-03 22:35 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: roel kluin @ 2008-10-29 21:06 UTC (permalink / raw)
  To: len.brown; +Cc: linux-kernel

max_state is unsigned, so the test is invalid.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
I think max_state can only become -1, no? then probably a different
patch is required.
I may not be able to respond for a few weeks.

diff --git a/drivers/misc/intel_menlow.c b/drivers/misc/intel_menlow.c
index e00a275..980171d 100644
--- a/drivers/misc/intel_menlow.c
+++ b/drivers/misc/intel_menlow.c
@@ -121,7 +121,7 @@ static int memory_set_cur_bandwidth(struct thermal_cooling_device *cdev,
 	if (memory_get_int_max_bandwidth(cdev, &max_state))
 		return -EFAULT;
 
-	if (max_state < 0 || state > max_state)
+	if (max_state == -1 || state > max_state)
 		return -EINVAL;
 
 	arg_list.count = 1;


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

* Re: [PATCH] intel_menlo: max_state is unsigned, invalid test
  2008-10-29 21:06 [PATCH] intel_menlo: max_state is unsigned, invalid test roel kluin
@ 2008-11-03 22:35 ` Andrew Morton
  2008-11-04  4:07   ` Len Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2008-11-03 22:35 UTC (permalink / raw)
  To: roel kluin; +Cc: len.brown, linux-kernel, linux-acpi

On Wed, 29 Oct 2008 17:06:47 -0400
roel kluin <roel.kluin@gmail.com> wrote:

> max_state is unsigned, so the test is invalid.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> I think max_state can only become -1, no? then probably a different
> patch is required.
> I may not be able to respond for a few weeks.
> 
> diff --git a/drivers/misc/intel_menlow.c b/drivers/misc/intel_menlow.c
> index e00a275..980171d 100644
> --- a/drivers/misc/intel_menlow.c
> +++ b/drivers/misc/intel_menlow.c
> @@ -121,7 +121,7 @@ static int memory_set_cur_bandwidth(struct thermal_cooling_device *cdev,
>  	if (memory_get_int_max_bandwidth(cdev, &max_state))
>  		return -EFAULT;
>  
> -	if (max_state < 0 || state > max_state)
> +	if (max_state == -1 || state > max_state)
>  		return -EINVAL;
>  
>  	arg_list.count = 1;
> 

hm, maybe.

This can only happen if acpi_evaluate_integer(MEMORY_GET_BANDWIDTH)
returned no-error and a bandwidth of zero (I assume).

Is this a special case which the driver really wanted to handle?  If
so, why is "0" the only bad value which we're checking for?  Or is this
all some big brainfart which should be removed?

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

* Re: [PATCH] intel_menlo: max_state is unsigned, invalid test
  2008-11-03 22:35 ` Andrew Morton
@ 2008-11-04  4:07   ` Len Brown
  2008-11-05 10:20     ` Thomas, Sujith
  0 siblings, 1 reply; 4+ messages in thread
From: Len Brown @ 2008-11-04  4:07 UTC (permalink / raw)
  To: Andrew Morton, Sujith Thomas, Zhang Rui
  Cc: roel kluin, len.brown, Linux Kernel Mailing List, linux-acpi



On Mon, 3 Nov 2008, Andrew Morton wrote:

> On Wed, 29 Oct 2008 17:06:47 -0400
> roel kluin <roel.kluin@gmail.com> wrote:
> 
> > max_state is unsigned, so the test is invalid.
> > 
> > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> > ---
> > I think max_state can only become -1, no? then probably a different
> > patch is required.
> > I may not be able to respond for a few weeks.
> > 
> > diff --git a/drivers/misc/intel_menlow.c b/drivers/misc/intel_menlow.c
> > index e00a275..980171d 100644
> > --- a/drivers/misc/intel_menlow.c
> > +++ b/drivers/misc/intel_menlow.c
> > @@ -121,7 +121,7 @@ static int memory_set_cur_bandwidth(struct thermal_cooling_device *cdev,
> >  	if (memory_get_int_max_bandwidth(cdev, &max_state))
> >  		return -EFAULT;
> >  
> > -	if (max_state < 0 || state > max_state)
> > +	if (max_state == -1 || state > max_state)
> >  		return -EINVAL;
> >  
> >  	arg_list.count = 1;
> > 
> 
> hm, maybe.
> 
> This can only happen if acpi_evaluate_integer(MEMORY_GET_BANDWIDTH)
> returned no-error and a bandwidth of zero (I assume).
> 
> Is this a special case which the driver really wanted to handle?  If
> so, why is "0" the only bad value which we're checking for?  Or is this
> all some big brainfart which should be removed?

Sujith,
Please send me a patch to intel_menlo.c that documents the
legal return values from GTHS.

If 0 is illegal, that is fine, but the upstream driver doesn't
check for it properl (I like Rui's 9/11 patch better than the above,
so andrew, you can drop this patch in any case)

thanks,
-Len

ps.  Sujith, shouldn't there be a MAINTAINERS for this driver with your 
name on it?




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

* RE: [PATCH] intel_menlo: max_state is unsigned, invalid test
  2008-11-04  4:07   ` Len Brown
@ 2008-11-05 10:20     ` Thomas, Sujith
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas, Sujith @ 2008-11-05 10:20 UTC (permalink / raw)
  To: Len Brown, Andrew Morton, Zhang, Rui
  Cc: roel kluin, Brown, Len, Linux Kernel Mailing List, linux-acpi



>-----Original Message-----
>From: Len Brown [mailto:lenb@kernel.org]
>Sent: Tuesday, November 04, 2008 9:37 AM
>To: Andrew Morton; Thomas, Sujith; Zhang, Rui
>Cc: roel kluin; Brown, Len; Linux Kernel Mailing List; linux-
>acpi@vger.kernel.org
>Subject: Re: [PATCH] intel_menlo: max_state is unsigned, invalid test
>
>
>
>On Mon, 3 Nov 2008, Andrew Morton wrote:
>
>> On Wed, 29 Oct 2008 17:06:47 -0400
>> roel kluin <roel.kluin@gmail.com> wrote:
>>
>> > max_state is unsigned, so the test is invalid.
>> >
>> > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>> > ---
>> > I think max_state can only become -1, no? then probably a different
>> > patch is required.
>> > I may not be able to respond for a few weeks.
>> >
>> > diff --git a/drivers/misc/intel_menlow.c
b/drivers/misc/intel_menlow.c
>> > index e00a275..980171d 100644
>> > --- a/drivers/misc/intel_menlow.c
>> > +++ b/drivers/misc/intel_menlow.c
>> > @@ -121,7 +121,7 @@ static int memory_set_cur_bandwidth(struct
>thermal_cooling_device *cdev,
>> >  	if (memory_get_int_max_bandwidth(cdev, &max_state))
>> >  		return -EFAULT;
>> >
>> > -	if (max_state < 0 || state > max_state)
>> > +	if (max_state == -1 || state > max_state)
>> >  		return -EINVAL;
>> >
>> >  	arg_list.count = 1;
>> >
>>
>> hm, maybe.
>>
>> This can only happen if acpi_evaluate_integer(MEMORY_GET_BANDWIDTH)
>> returned no-error and a bandwidth of zero (I assume).
>>
>> Is this a special case which the driver really wanted to handle?  If
>> so, why is "0" the only bad value which we're checking for?  Or is
this
>> all some big brainfart which should be removed?
>
>Sujith,
>Please send me a patch to intel_menlo.c that documents the
>legal return values from GTHS.
>
>If 0 is illegal, that is fine, but the upstream driver doesn't
>check for it properl (I like Rui's 9/11 patch better than the above,
>so andrew, you can drop this patch in any case)
>
>thanks,
>-Len
>
>ps.  Sujith, shouldn't there be a MAINTAINERS for this driver with your
>name on it?
>
>
Hi Len,
I am also in agreement that Rui's 9/11 patch is the solution.
I'll be sending out patches you requested.
These can be applied over Rui's 9/11 patch.

Regards,
Sujith
	

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

end of thread, other threads:[~2008-11-05 10:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-29 21:06 [PATCH] intel_menlo: max_state is unsigned, invalid test roel kluin
2008-11-03 22:35 ` Andrew Morton
2008-11-04  4:07   ` Len Brown
2008-11-05 10:20     ` Thomas, Sujith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).