diff mbox

[25/26] cpu_cooling: Use cpufreq_dev->freq_table for finding level/freq

Message ID CAKohponQ0vr7QXFun3GmPsMCGj6VOd3P0of6Hd5p4ZBG-_PxdQ@mail.gmail.com
State New
Headers show

Commit Message

Viresh Kumar Dec. 3, 2014, 5:10 a.m. UTC
On 3 December 2014 at 05:06, Eduardo Valentin <edubezval@gmail.com> wrote:
>> -     ret = get_property(cpufreq_device, state, &clip_freq, GET_FREQ);
>> -     if (ret)
>> -             return ret;
>> -
>> +     clip_freq = cpufreq_device->freq_table[state];
>
> There should be some check for valid state here..

What about this ??

                return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 6bd95bc..6e76417 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -228,6 +228,10 @@  static int cpufreq_set_cur_state(struct
thermal_cooling_device *cdev,
        unsigned int cpu = cpumask_any(&cpufreq_device->allowed_cpus);
        unsigned int clip_freq;

+       /* Request state should be less than max_level */
+       if (WARN_ON(state > cpufreq_device->max_level))
+               return -EINVAL;
+
        /* Check if the old cooling action is same as new cooling action */
        if (cpufreq_device->cpufreq_state == state)