PM / devfreq: Fix NULL pointer dereference if freq_table is empty
If max_state is 0, freq_table will be empty. Change do-while loop to while loop to avoid dereferencing freq_table. Change-Id: I4a24e9b8cab8073db429c74e627b7fb50076ea93 Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
This commit is contained in:
parent
d207221fad
commit
45f7fa7337
1 changed files with 2 additions and 2 deletions
|
@ -1001,7 +1001,7 @@ static ssize_t available_frequencies_show(struct device *d,
|
|||
|
||||
rcu_read_lock();
|
||||
use_opp = dev_pm_opp_get_opp_count(dev) > 0;
|
||||
do {
|
||||
while (use_opp || (!use_opp && i < max_state)) {
|
||||
if (use_opp) {
|
||||
opp = dev_pm_opp_find_freq_ceil(dev, &freq);
|
||||
if (IS_ERR(opp))
|
||||
|
@ -1013,7 +1013,7 @@ static ssize_t available_frequencies_show(struct device *d,
|
|||
count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
|
||||
"%lu ", freq);
|
||||
freq++;
|
||||
} while (use_opp || (!use_opp && i < max_state));
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
/* Truncate the trailing space */
|
||||
|
|
Loading…
Add table
Reference in a new issue