From: Huang Rui Date: Wed, 20 Feb 2019 12:00:21 +0000 (+0800) Subject: drm/amdgpu: fix the issue of checking on message mapping X-Git-Tag: v5.15~5873^2~13^2~326 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c16d001bf261b70b90463248a2a99628e1fae6f8;p=platform%2Fkernel%2Flinux-starfive.git drm/amdgpu: fix the issue of checking on message mapping The navi10_message_map[index] scope should be in PPSMC_Message_Count not in SMU_MSG_MAX_COUNT. Signed-off-by: Huang Rui Reviewed-by: Hawking Zhang Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c index 7fb2a06..a233f34 100644 --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c @@ -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