1
0
Fork 0

MLK-14668 cpufreq: interactive: check index before using it

This also fixes the following warning:

drivers/cpufreq/cpufreq_interactive.c: In function 'choose_freq':
drivers/cpufreq/cpufreq_interactive.c:284:7: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if (ret)
           ^

Signed-off-by: Octavian Purdila <octavian.purdila@nxp.com>
steinar/wifi_calib_4_9_kernel
Octavian Purdila 2017-04-11 09:31:33 +03:00 committed by Anson Huang
parent 9c0059ad51
commit 0d1f158226
1 changed files with 5 additions and 3 deletions

View File

@ -255,7 +255,7 @@ static unsigned int choose_freq(struct interactive_cpu *icpu,
struct cpufreq_frequency_table *freq_table = policy->freq_table;
unsigned int prevfreq, freqmin = 0, freqmax = UINT_MAX, tl;
unsigned int freq = policy->cur;
int index, ret;
int index;
do {
prevfreq = freq;
@ -268,6 +268,8 @@ static unsigned int choose_freq(struct interactive_cpu *icpu,
index = cpufreq_frequency_table_target(policy, loadadjfreq / tl,
CPUFREQ_RELATION_L);
if (index < 0)
break;
freq = freq_table[index].frequency;
@ -281,7 +283,7 @@ static unsigned int choose_freq(struct interactive_cpu *icpu,
/* Find highest frequency that is less than freqmax */
index = cpufreq_frequency_table_target(policy,
freqmax - 1, CPUFREQ_RELATION_H);
if (ret)
if (index < 0)
break;
freq = freq_table[index].frequency;
@ -305,7 +307,7 @@ static unsigned int choose_freq(struct interactive_cpu *icpu,
/* Find lowest frequency that is higher than freqmin */
index = cpufreq_frequency_table_target(policy,
freqmin + 1, CPUFREQ_RELATION_L);
if (ret)
if (index < 0)
break;
freq = freq_table[index].frequency;