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: cb33363d0e ("drm/amd/powerplay: add smu feature name support")
Fixes: 6b294793e3 ("drm/amd/powerplay: add smu message name support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Colin Ian King 2019-08-01 12:15:41 +01:00 committed by Alex Deucher
parent 6f7fe9a93e
commit e3bf125bdb
1 changed files with 2 additions and 2 deletions

View File

@ -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];
}