Skip to contentSkip to conversation

Thermal: cpufreq cooling: endian bug in cpufreq_get_max_state()

PATCH Applied Dan Carpenter 3 participants 3 messages Apr 17, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Thermal: cpufreq cooling: endian bug in cpufreq_get_max_state()

This code doesn't work on big endian systems because we're storing low values in the high bits of the unsigned long. It makes it a very high value instead.

drivers/thermal/cpu_cooling.c +2 -2
index 5f5c780..768b508 100644
@@ -303,12 +303,12 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev,
 	struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
 	struct cpumask *mask = &cpufreq_device->allowed_cpus;
 	unsigned int cpu;
-	unsigned long count = 0;
+	unsigned int count = 0;
 	int ret;
 
 	cpu = cpumask_any(mask);
 
-	ret = get_property(cpu, 0, (unsigned int *)&count, GET_MAXL);
+	ret = get_property(cpu, 0, &count, GET_MAXL);
 
 	if (count > 0)
 		*state = count;
reviewer Applied
#1 lore raw
Quoted 5 lines · Dan Carpenter

This code doesn't work on big endian systems because we're storing low values in the high bits of the unsigned long. It makes it a very high value instead.

applied to thermal -next.

thanks,
rui

Quoted 20 lines
drivers/thermal/cpu_cooling.c +2 -2
index 5f5c780..768b508 100644
@@ -303,12 +303,12 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev,
 	struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
 	struct cpumask *mask = &cpufreq_device->allowed_cpus;
 	unsigned int cpu;
-	unsigned long count = 0;
+	unsigned int count = 0;
 	int ret;
 
 	cpu = cpumask_any(mask);
 
-	ret = get_property(cpu, 0, (unsigned int *)&count, GET_MAXL);
+	ret = get_property(cpu, 0, &count, GET_MAXL);
 
 	if (count > 0)
 		*state = count;
Acked-by Tested-by
#2 lore raw
Quoted 8 lines · Zhang Rui
Quoted 5 lines · Dan Carpenter

This code doesn't work on big endian systems because we're storing low values in the high bits of the unsigned long. It makes it a very high value instead.

applied to thermal -next.

Rui,

Can you please add also my:

Tested on TI OMAP4430.

Quoted 31 lines

thanks,
rui

Quoted 10 lines
drivers/thermal/cpu_cooling.c +0 -1
index 5f5c780..768b508 100644
@@ -303,12 +303,12 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev,
  	struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
  	struct cpumask *mask = &cpufreq_device->allowed_cpus;
  	unsigned int cpu;
-	unsigned long count = 0;

drivers/thermal/cpu_cooling.c static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, · line 314

Quoted 10 lines
drivers/thermal/cpu_cooling.c +2 -1
+	unsigned int count = 0;
  	int ret;
 
  	cpu = cpumask_any(mask);
 
-	ret = get_property(cpu, 0, (unsigned int *)&count, GET_MAXL);
+	ret = get_property(cpu, 0, &count, GET_MAXL);
 
  	if (count > 0)
  		*state = count;

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html