[PATCH] drm/amd/powerplay: fix off-by-one array bounds check

Abramov, Slava Slava.Abramov at amd.com
Fri Jun 28 15:15:37 UTC 2019


Acked-by: Slava Abramov <slava.abramov at amd.com>

________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Colin King <colin.king at canonical.com>
Sent: Friday, June 28, 2019 10:24:02 AM
To: Rex Zhu; Quan, Evan; Deucher, Alexander; Koenig, Christian; Zhou, David(ChunMing); David Airlie; Daniel Vetter; amd-gfx at lists.freedesktop.org; dri-devel at lists.freedesktop.org
Cc: kernel-janitors at vger.kernel.org; linux-kernel at vger.kernel.org
Subject: [PATCH] drm/amd/powerplay: fix off-by-one array bounds check

From: Colin Ian King <colin.king at canonical.com>

The array bounds check for index is currently off-by-one and should
be using >= rather than > on the upper bound. Fix this.

Addresses-Coverity: ("Out-of-bounds read")
Fixes: b3490673f905 ("drm/amd/powerplay: introduce the navi10 pptable implementation")
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index 27e5c80..f678700 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -210,7 +210,7 @@ static int navi10_workload_map[] = {
 static int navi10_get_smu_msg_index(struct smu_context *smc, uint32_t index)
 {
         int val;
-       if (index > SMU_MSG_MAX_COUNT)
+       if (index >= SMU_MSG_MAX_COUNT)
                 return -EINVAL;

         val = navi10_message_map[index];
--
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20190628/e6654ed9/attachment.html>


More information about the amd-gfx mailing list