drm/amd/powerplay: fix the issue of checking on message mapping
authorHuang Rui <ray.huang@amd.com>
Mon, 25 Feb 2019 11:43:00 +0000 (19:43 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:04:02 +0000 (15:04 -0500)
The vega20_message_map[index] scope should be in PPSMC_Message_Count not in
SMU_MSG_MAX_COUNT.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index e6db56d158eb632caf474c7d9b5f344b65e1bad4..6763dcd21cf19813a5e4468c2edec4cf26265033 100644 (file)
@@ -131,10 +131,15 @@ static int vega20_message_map[SMU_MSG_MAX_COUNT] = {
 
 static int vega20_get_smu_msg_index(struct smu_context *smc, uint32_t index)
 {
-       if (index > SMU_MSG_MAX_COUNT || index > PPSMC_Message_Count)
+       int val;
+       if (index > SMU_MSG_MAX_COUNT)
                return -EINVAL;
-       return vega20_message_map[index];
 
+       val = vega20_message_map[index];
+       if (val > PPSMC_Message_Count)
+               return -EINVAL;
+
+       return val;
 }
 
 static int vega20_allocate_dpm_context(struct smu_context *smu)