drm/amd/powerplay: off by one bugs in smu_cmn_to_asic_specific_index()
Subsystems (3)
PATCH 1/1 drm/amd/powerplay: off by one bugs in smu_cmn_to_asic_specific_index()
These tables have _COUNT number of elements so the comparisons should be
Quoted 1 line
= instead of > to prevent reading one element beyond the end of the
array.
Fixes 8264ee69f0d8 ("drm/amd/powerplay: drop unused code")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/gpu/drm/amd/powerplay/smu_cmn.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/powerplay/smu_cmn.c +5 -5
@@ -166,7 +166,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,switch (type) {case CMN2ASIC_MAPPING_MSG : -if (index >SMU_MSG_MAX_COUNT || +if (index >=SMU_MSG_MAX_COUNT || !smu->message_map)return -EINVAL ;
@@ -181,7 +181,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,return msg_mapping.map_to;case CMN2ASIC_MAPPING_CLK : -if (index >SMU_CLK_COUNT || +if (index >=SMU_CLK_COUNT || !smu->clock_map)return -EINVAL ;
@@ -192,7 +192,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,return mapping.map_to;case CMN2ASIC_MAPPING_FEATURE : -if (index >SMU_FEATURE_COUNT || +if (index >=SMU_FEATURE_COUNT || !smu->feature_map)return -EINVAL ;
@@ -203,7 +203,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,return mapping.map_to;case CMN2ASIC_MAPPING_TABLE : -if (index >SMU_TABLE_COUNT || +if (index >=SMU_TABLE_COUNT || !smu->table_map)return -EINVAL ;
@@ -214,7 +214,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,return mapping.map_to;case CMN2ASIC_MAPPING_PWR : -if (index >SMU_POWER_SOURCE_COUNT || +if (index >=SMU_POWER_SOURCE_COUNT || !smu->pwr_src_map)return -EINVAL ;
Signature · 1 line
2.27.0
Alex Deucher
AppliedQuoted 7 lines · Dan Carpenter
These tables have
_COUNTnumber of elements so the comparisons should beQuoted 1 line
= instead of > to prevent reading one element beyond the end of the
array.
Fixes 8264ee69f0d8 ("drm/amd/powerplay: drop unused code")Signed-off-by Dan Carpenter <[email protected]>
Applied. Thanks!
Alex
Quoted 60 lines
--- drivers/gpu/drm/amd/powerplay/smu_cmn.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/powerplay/smu_cmn.c +5
-6@@ -166,7 +166,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,switch (type) {case CMN2ASIC_MAPPING_MSG : -if (index >SMU_MSG_MAX_COUNT || +if (index >=SMU_MSG_MAX_COUNT || !smu->message_map)return -EINVAL ;@@ -181,7 +181,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,return msg_mapping.map_to;case CMN2ASIC_MAPPING_CLK : -if (index >SMU_CLK_COUNT || +if (index >=SMU_CLK_COUNT || !smu->clock_map)return -EINVAL ;@@ -192,7 +192,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,return mapping.map_to;case CMN2ASIC_MAPPING_FEATURE : -if (index >SMU_FEATURE_COUNT || +if (index >=SMU_FEATURE_COUNT || !smu->feature_map)return -EINVAL ;@@ -203,7 +203,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,return mapping.map_to;case CMN2ASIC_MAPPING_TABLE : -if (index >SMU_TABLE_COUNT || +if (index >=SMU_TABLE_COUNT || !smu->table_map)return -EINVAL ;@@ -214,7 +214,7 @@ int smu_cmn_to_asic_specific_index(struct smu_context *smu,return mapping.map_to;case CMN2ASIC_MAPPING_PWR : -if (index >SMU_POWER_SOURCE_COUNT || +if (index >=SMU_POWER_SOURCE_COUNT || !smu->pwr_src_map)return -EINVAL ; --2.27.0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx