Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=53391fa20cab6df6b476a5a0ad6be653c9de0c46
Commit:     53391fa20cab6df6b476a5a0ad6be653c9de0c46
Parent:     1ce357129a55a791318e23f5d7b8a9f1352858aa
Author:     Yi Yang <[EMAIL PROTECTED]>
AuthorDate: Wed Jan 30 13:33:34 2008 +0100
Committer:  Ingo Molnar <[EMAIL PROTECTED]>
CommitDate: Wed Jan 30 13:33:34 2008 +0100

    cpufreq: fix obvious condition statement error
    
    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]>
    Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
    Signed-off-by: Thomas Gleixner <[EMAIL PROTECTED]>
---
 drivers/cpufreq/cpufreq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 5efd555..b730d67 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1604,7 +1604,7 @@ static int __cpufreq_set_policy(struct cpufreq_policy 
*data,
        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;
        }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to