diff options
| author | Dan Carpenter <[email protected]> | 2024-10-10 18:35:36 +0000 |
|---|---|---|
| committer | Alex Deucher <[email protected]> | 2024-10-15 15:26:35 +0000 |
| commit | 9f7e94af35996effead76ff2837b5ba322e38963 (patch) | |
| tree | 57e4801a2d720d80780ca4bbec503c4bc890ddcf /drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | |
| parent | drm/amdgpu/swsmu: default to fullscreen 3D profile for dGPUs (diff) | |
| download | kernel-9f7e94af35996effead76ff2837b5ba322e38963.tar.gz kernel-9f7e94af35996effead76ff2837b5ba322e38963.zip | |
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: 012be6f22c01 ("drm/amdgpu: Add sysfs interfaces for NPS mode")
Reviewed-by: Lijo Lazar <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c index 4e0a2d86a726..1c19a65e6553 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"); |
