mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH next] drm/amdgpu: Fix off by one in current_memory_partition_show()
@ 2024-10-10 18:35 Dan Carpenter
  2024-10-11  3:05 ` Lazar, Lijo
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-10-10 18:35 UTC (permalink / raw)
  To: Lijo Lazar
  Cc: Alex Deucher, Christian König, Xinhui Pan, David Airlie,
	Simona Vetter, Hawking Zhang, Yunxiang Li, Srinivasan Shanmugam,
	Dr. David Alan Gilbert, Rajneesh Bhardwaj, amd-gfx, dri-devel,
	linux-kernel, kernel-janitors

The >= ARRAY_SIZE() should be > ARRAY_SIZE() to prevent an out of
bounds read.

Fixes: 012be6f22c01 ("drm/amdgpu: Add sysfs interfaces for NPS mode")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index ddf716d27f3a..75c9291ac3eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -1199,7 +1199,7 @@ static ssize_t current_memory_partition_show(
 	enum amdgpu_memory_partition mode;
 
 	mode = adev->gmc.gmc_funcs->query_mem_partition_mode(adev);
-	if ((mode > ARRAY_SIZE(nps_desc)) ||
+	if ((mode >= ARRAY_SIZE(nps_desc)) ||
 	    (BIT(mode) & AMDGPU_ALL_NPS_MASK) != BIT(mode))
 		return sysfs_emit(buf, "UNKNOWN\n");
 
-- 
2.45.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-14 18:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10 18:35 [PATCH next] drm/amdgpu: Fix off by one in current_memory_partition_show() Dan Carpenter
2024-10-11  3:05 ` Lazar, Lijo
2024-10-14 18:04   ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®