Skip to contentSkip to conversation

cpufreq: Fix null object access on Transmeta CPU

PATCH New CHIKAMA masaki 1 participant 1 message May 9, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: Fix null object access on Transmeta CPU

If cpu specific cpufreq driver(i.e. longrun) has "setpolicy" function, governor object isn't set into cpufreq_policy object at "__cpufreq_set_policy" function in driver/cpufreq/cpufreq.c .

This cause null object access at "store_scaling_setspeed" and "show_scaling_setspeed" function in driver/cpufreq/cpufreq.c when reading or writing through /sys interface
(ex. cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed)

Here is a proposed patch to check governor against 2.6.25.

---

cpufreq/cpufreq.c renamed from cpufreq/cpufreq.c.org +2 -2
@@ -607,7 +607,7 @@ static ssize_t store_scaling_setspeed(st
 	unsigned int freq = 0;
 	unsigned int ret;
 
-	if (!policy->governor->store_setspeed)
+	if (!policy->governor || !policy->governor->store_setspeed)
 		return -EINVAL;
 
 	ret = sscanf(buf, "%u", &freq);
@@ -621,7 +621,7 @@ static ssize_t store_scaling_setspeed(st
 
 static ssize_t show_scaling_setspeed(struct cpufreq_policy *policy, char *buf)
 {
-	if (!policy->governor->show_setspeed)
+	if (!policy->governor || !policy->governor->show_setspeed)
 		return sprintf(buf, "<unsupported>\n");
 
 	return policy->governor->show_setspeed(policy, buf);