Skip to contentSkip to conversation

thermal: cpu_cooling: fix 'descend' check in get_property()

PATCH New Shawn Guo 2 participants 2 messages May 28, 2013 Thermal

lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

PATCH 1/1 thermal: cpu_cooling: fix 'descend' check in get_property()

The variable 'descend' is initialized as -1 in function get_property(), and will never get any chance to be updated by the following code.

	if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
		descend = !!(freq > table[i].frequency);

This makes function get_property() return the wrong frequency for given cooling level if the frequency table is sorted in ascending. Fix it by correcting the 'descend' check in if-condition to 'descend == -1'.

---
 drivers/thermal/cpu_cooling.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/cpu_cooling.c +1 -1
index c94bf2e..82e15db 100644
@@ -167,7 +167,7 @@ static int get_property(unsigned int cpu, unsigned long input,
 			continue;
 
 		/* get the frequency order */
-		if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
+		if (freq != CPUFREQ_ENTRY_INVALID && descend == -1)
 			descend = !!(freq > table[i].frequency);
 
 		freq = table[i].frequency;
Signature · 1 line
1.7.9.5
reviewer
#1 lore raw

PATCH 1/1 thermal: cpu_cooling: fix 'descend' check in get_property()

Quoted 11 lines · Shawn Guo

The variable 'descend' is initialized as -1 in function get_property(), and will never get any chance to be updated by the following code.

	if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
		descend = !!(freq > table[i].frequency);

This makes function get_property() return the wrong frequency for given cooling level if the frequency table is sorted in ascending. Fix it by correcting the 'descend' check in if-condition to 'descend == -1'.

good catch!
patch applied to thermal -next.

thanks,
rui

Quoted 17 lines
---
 drivers/thermal/cpu_cooling.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/cpu_cooling.c +1 -1
index c94bf2e..82e15db 100644
@@ -167,7 +167,7 @@ static int get_property(unsigned int cpu, unsigned long input,
 			continue;
 
 		/* get the frequency order */
-		if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
+		if (freq != CPUFREQ_ENTRY_INVALID && descend == -1)
 			descend = !!(freq > table[i].frequency);
 
 		freq = table[i].frequency;