mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-18 06:33:43 -04:00
drm/amdgpu: Fix off by one in current_memory_partition_show()
The >= ARRAY_SIZE() should be > ARRAY_SIZE() to prevent an out of
bounds read.
Fixes: 012be6f22c ("drm/amdgpu: Add sysfs interfaces for NPS mode")
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
336568de91
commit
9f7e94af35
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user