* [PATCH][drm-next] drm/amd/powerplay: fix off-by-one upper bounds limit checks
@ 2019-08-01 11:15 Colin King
2019-08-01 18:53 ` Alex Deucher
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-08-01 11:15 UTC (permalink / raw)
To: Kevin Wang, Rex Zhu, Evan Quan, Alex Deucher,
Christian König, David Zhou, David Airlie, Daniel Vetter,
amd-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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: cb33363d0e85 ("drm/amd/powerplay: add smu feature name support")
Fixes: 6b294793e384 ("drm/amd/powerplay: add smu message name support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index d029a99e600e..b64113740eb5 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -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 "unknown 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 "unknown smu feature";
return __smu_feature_names[feature];
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][drm-next] drm/amd/powerplay: fix off-by-one upper bounds limit checks
2019-08-01 11:15 [PATCH][drm-next] drm/amd/powerplay: fix off-by-one upper bounds limit checks Colin King
@ 2019-08-01 18:53 ` Alex Deucher
0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2019-08-01 18:53 UTC (permalink / raw)
To: Colin King
Cc: Kevin Wang, Rex Zhu, Evan Quan, Alex Deucher,
Christian König, David Zhou, David Airlie, Daniel Vetter,
amd-gfx list, Maling list - DRI developers, kernel-janitors,
LKML
On Thu, Aug 1, 2019 at 7:15 AM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> 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: cb33363d0e85 ("drm/amd/powerplay: add smu feature name support")
> Fixes: 6b294793e384 ("drm/amd/powerplay: add smu message name support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied. thanks!
Alex
> ---
> drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index d029a99e600e..b64113740eb5 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -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 "unknown 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 "unknown smu feature";
> return __smu_feature_names[feature];
> }
> --
> 2.20.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-01 18:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-01 11:15 [PATCH][drm-next] drm/amd/powerplay: fix off-by-one upper bounds limit checks Colin King
2019-08-01 18:53 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).