]> Pileus Git - ~andy/linux/blobdiff - drivers/cpufreq/cpufreq.c
cpufreq: Make sure target freq is within limits
[~andy/linux] / drivers / cpufreq / cpufreq.c
index 28dc134cec3696b4d16ab6ce03995e600190e065..2f5ac2dcfda6b0c899b99179bfcb91dab942554f 100644 (file)
@@ -1470,12 +1470,19 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
                            unsigned int relation)
 {
        int retval = -EINVAL;
+       unsigned int old_target_freq = target_freq;
 
        if (cpufreq_disabled())
                return -ENODEV;
 
-       pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
-               target_freq, relation);
+       /* Make sure that target_freq is within supported range */
+       if (target_freq > policy->max)
+               target_freq = policy->max;
+       if (target_freq < policy->min)
+               target_freq = policy->min;
+
+       pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
+                       policy->cpu, target_freq, relation, old_target_freq);
 
        if (target_freq == policy->cur)
                return 0;