Skip to content

Commit 1e7f219

Browse files
committed
clk: clamp frequency index when no threshold matches
When the requested frequency was at least every table entry, the search index ran off the end of the table and the following access read one element past it. Clamp the index to the last valid entry. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 27ae44b commit 1e7f219

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/lib/cpu-clk-manager.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ static int request_freq_change(unsigned int core, int freq)
2828
break;
2929
}
3030

31+
/* if no entry was larger than the requested frequency the loop runs off
32+
* the end of the table; clamp to the last valid entry before indexing
33+
*/
34+
if (selected_freq_id >= clk->freqs_num)
35+
selected_freq_id = clk->freqs_num - 1;
36+
3137
/* don't change clock frequency if already using proper clock */
3238
current_freq = clock_get_freq(core);
3339
if (clk->freqs[selected_freq_id].freq != current_freq)

0 commit comments

Comments
 (0)