Commit e3bf125b authored by Colin Ian King's avatar Colin Ian King Committed by Alex Deucher

drm/amd/powerplay: fix off-by-one upper bounds limit checks

There are two occurrances of off-by-one upper bound checking of indexes
causing potential out-of-bounds array reads. Fix these.

Addresses-Coverity: ("Out-of-bounds read")
Fixes: cb33363d ("drm/amd/powerplay: add smu feature name support")
Fixes: 6b294793 ("drm/amd/powerplay: add smu message name support")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6f7fe9a9
......@@ -38,7 +38,7 @@ static const char* __smu_message_names[] = {
const char *smu_get_message_name(struct smu_context *smu, enum smu_message_type type)
{
if (type < 0 || type > SMU_MSG_MAX_COUNT)
if (type < 0 || type >= SMU_MSG_MAX_COUNT)
return "unknow smu message";
return __smu_message_names[type];
}
......@@ -51,7 +51,7 @@ static const char* __smu_feature_names[] = {
const char *smu_get_feature_name(struct smu_context *smu, enum smu_feature_mask feature)
{
if (feature < 0 || feature > SMU_FEATURE_COUNT)
if (feature < 0 || feature >= SMU_FEATURE_COUNT)
return "unknow smu feature";
return __smu_feature_names[feature];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment