From 8513027a73c2f2d9a4d4c82e3e805b2f9219767f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 21 Mar 2019 12:19:57 +0300 Subject: [PATCH] drm/amd/powerplay: Off by one in vega20_get_smu_msg_index() The > should be >= so that we don't read one element beyond the end of the vega20_message_map[] array. Fixes: 78031c2c4dcd ("drm/amd/powerplay: implement smu vega20_message_map for vega20") Reviewed-by: Kevin Wang Signed-off-by: Dan Carpenter Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c index 41e6f49..8fafcbd 100644 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c @@ -132,7 +132,8 @@ static int vega20_message_map[SMU_MSG_MAX_COUNT] = { static int vega20_get_smu_msg_index(struct smu_context *smc, uint32_t index) { int val; - if (index > SMU_MSG_MAX_COUNT) + + if (index >= SMU_MSG_MAX_COUNT) return -EINVAL; val = vega20_message_map[index]; -- 2.7.4