The patch titled
cpufreq: fix obvious condition statement error
has been added to the -mm tree. Its filename is
cpufreq-fix-obvious-condition-statement-error.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
Subject: cpufreq: fix obvious condition statement error
From: Yi Yang <[EMAIL PROTECTED]>
The function __cpufreq_set_policy in file drivers/cpufreq/cpufreq.c
has a very obvious error:
if (policy->min > data->min && policy->min > policy->max) {
ret = -EINVAL;
goto error_out;
}
This condtion statement is wrong because it returns -EINVAL only if
policy->min is greater than policy->max (in this case,
"policy->min > data->min" is true for ever.). In fact, it should
return -EINVAL as well if policy->max is less than data->min.
The correct condition should be:
if (policy->min > data->max || policy->max < data->min) {
The following test result testifies the above conclusion:
Before applying this patch:
[EMAIL PROTECTED] /]# cat
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
2394000 1596000
[EMAIL PROTECTED] /]# echo 1596000 >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1596000
[EMAIL PROTECTED] /]# echo "2000000" >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
-bash: echo: write error: Invalid argument
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1596000
[EMAIL PROTECTED] /]# echo "0" >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[EMAIL PROTECTED] /]# echo "1595000" >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[EMAIL PROTECTED] /]#
After applying this patch:
[EMAIL PROTECTED] /]# cat
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
2394000 1596000
[EMAIL PROTECTED] /]# echo 1596000 >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1596000
[EMAIL PROTECTED] /]# echo "2000000" >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
-bash: echo: write error: Invalid argument
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
1596000
[EMAIL PROTECTED] /]# echo "0" >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
-bash: echo: write error: Invalid argument
[EMAIL PROTECTED] /]# echo "1595000" >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
-bash: echo: write error: Invalid argument
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1596000
[EMAIL PROTECTED] /]# echo "1596000" >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[EMAIL PROTECTED] /]# echo "2394000" >
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[EMAIL PROTECTED] /]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
2394000
[EMAIL PROTECTED] /]
Signed-off-by: Yi Yang <[EMAIL PROTECTED]>
Cc: Dave Jones <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Cc: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---
drivers/cpufreq/cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -puN
drivers/cpufreq/cpufreq.c~cpufreq-fix-obvious-condition-statement-error
drivers/cpufreq/cpufreq.c
--- a/drivers/cpufreq/cpufreq.c~cpufreq-fix-obvious-condition-statement-error
+++ a/drivers/cpufreq/cpufreq.c
@@ -1635,7 +1635,7 @@ static int __cpufreq_set_policy(struct c
memcpy(&policy->cpuinfo, &data->cpuinfo,
sizeof(struct cpufreq_cpuinfo));
- if (policy->min > data->min && policy->min > policy->max) {
+ if (policy->min > data->max || policy->max < data->min) {
ret = -EINVAL;
goto error_out;
}
_
Patches currently in -mm which might be from [EMAIL PROTECTED] are
git-acpi.patch
cpufreq-fix-obvious-condition-statement-error.patch
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html