drm/amdgpu: fix array out of bounds
authortom will <os@iscas.ac.cn>
Mon, 16 May 2016 14:31:07 +0000 (10:31 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 16 May 2016 14:31:07 +0000 (10:31 -0400)
When the initial value of i is greater than zero,
it may cause endless loop, resulting in array out
of bounds, fix it.

This is a port of the radeon fix to amdgpu.

Signed-off-by: tom will <os@iscas.ac.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/kv_dpm.c

index b45f54714574431f925712c73c11e4e40aa24004..a789a863d677faf641bb626022123ec20a46082f 100644 (file)
@@ -2252,7 +2252,7 @@ static void kv_apply_state_adjust_rules(struct amdgpu_device *adev,
        if (pi->caps_stable_p_state) {
                stable_p_state_sclk = (max_limits->sclk * 75) / 100;
 
-               for (i = table->count - 1; i >= 0; i++) {
+               for (i = table->count - 1; i >= 0; i--) {
                        if (stable_p_state_sclk >= table->entries[i].clk) {
                                stable_p_state_sclk = table->entries[i].clk;
                                break;