lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 6 Dec 2013 09:52:23 -0400
From:	Eduardo Valentin <eduardo.valentin@...com>
To:	Eduardo Valentin <eduardo.valentin@...com>
CC:	<rui.zhang@...el.com>, <linux-pm@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] thermal: fix cpu_cooling max_level behavior

On 13-11-2013 14:11, Eduardo Valentin wrote:
> As per Documentation/thermal/sysfs-api.txt, max_level
> is an index, not a counter. Thus, in case a CPU has
> 3 valid frequencies, max_level is expected to be 2, for instance.
> 
> The current code makes max_level == number of valid frequencies,
> which is bogus. This patch fix the cpu_cooling device by
> ranging max_level properly.
> 
> Reported-by: Carlos Hernandez <ceh@...com>
> Signed-off-by: Eduardo Valentin <eduardo.valentin@...com>

Rui,

Can you please consider pushing this fix?

> ---
>  drivers/thermal/cpu_cooling.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index d179028..d0f8f8b5 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -173,6 +173,8 @@ static int get_property(unsigned int cpu, unsigned long input,
>  		freq = table[i].frequency;
>  		max_level++;
>  	}
> +	/* max_level is an index, not a counter */
> +	max_level--;
>  
>  	/* get max level */
>  	if (property == GET_MAXL) {
> @@ -181,7 +183,7 @@ static int get_property(unsigned int cpu, unsigned long input,
>  	}
>  
>  	if (property == GET_FREQ)
> -		level = descend ? input : (max_level - input - 1);
> +		level = descend ? input : (max_level - input);
>  
>  	for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
>  		/* ignore invalid entry */
> @@ -197,7 +199,7 @@ static int get_property(unsigned int cpu, unsigned long input,
>  
>  		if (property == GET_LEVEL && (unsigned int)input == freq) {
>  			/* get level by frequency */
> -			*output = descend ? j : (max_level - j - 1);
> +			*output = descend ? j : (max_level - j);
>  			return 0;
>  		}
>  		if (property == GET_FREQ && level == j) {
> 


-- 
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin


Download attachment "signature.asc" of type "application/pgp-signature" (296 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ