From: Huang Rui Date: Mon, 25 Feb 2019 11:43:00 +0000 (+0800) Subject: drm/amd/powerplay: fix the issue of checking on message mapping X-Git-Tag: v5.15~6346^2~36^2~200 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04cfc0c80d8a9a727929b589954757823c22e445;p=platform%2Fkernel%2Flinux-starfive.git drm/amd/powerplay: fix the issue of checking on message mapping The vega20_message_map[index] scope should be in PPSMC_Message_Count not in SMU_MSG_MAX_COUNT. Signed-off-by: Huang Rui Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c index e6db56d..6763dcd 100644 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c @@ -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)