Skip to content

Commit

Permalink
drm/amd/powerplay: fix off-by-one upper bounds limit checks
Browse files Browse the repository at this point in the history
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: cb33363 ("drm/amd/powerplay: add smu feature name support")
Fixes: 6b29479 ("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>
  • Loading branch information
Colin Ian King authored and Alex Deucher committed Aug 2, 2019
1 parent 6f7fe9a commit e3bf125
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand All @@ -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];
}
Expand Down

0 comments on commit e3bf125

Please sign in to comment.