Skip to content

Commit cdb82ec

Browse files
committed
drm/amdgpu/mmhub3.0: add bounds checking for cid
The value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway. Reviewed-by: Benjamin Cheng <benjamin.cheng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit f14f27b) Cc: stable@vger.kernel.org
1 parent e5e6d67 commit cdb82ec

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ mmhub_v3_0_print_l2_protection_fault_status(struct amdgpu_device *adev,
110110
switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
111111
case IP_VERSION(3, 0, 0):
112112
case IP_VERSION(3, 0, 1):
113-
mmhub_cid = mmhub_client_ids_v3_0_0[cid][rw];
113+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v3_0_0) ?
114+
mmhub_client_ids_v3_0_0[cid][rw] : NULL;
114115
break;
115116
default:
116117
mmhub_cid = NULL;

0 commit comments

Comments
 (0)