drm/amdgpu: fix the issue of checking on message mapping
authorHuang Rui <ray.huang@amd.com>
Wed, 20 Feb 2019 12:00:21 +0000 (20:00 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 21 Jun 2019 23:59:24 +0000 (18:59 -0500)
The navi10_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: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/navi10_ppt.c

index 7fb2a0600dfb4e325fcf1095914f99478153a2ee..a233f34313e985067ca3e085bc1cb8a9de66f800 100644 (file)
@@ -101,10 +101,15 @@ static int navi10_message_map[SMU_MSG_MAX_COUNT] = {
 
 static int navi10_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 navi10_message_map[index];
 
+       val = navi10_message_map[index];
+       if (val > PPSMC_Message_Count)
+               return -EINVAL;
+
+       return val;
 }
 
 static int