Skip to content

Commit 9c52f49

Browse files
committed
drm/amdgpu/mmhub4.2.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 dea5f23) Cc: stable@vger.kernel.org
1 parent 3cdd405 commit 9c52f49

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,8 @@ mmhub_v4_2_0_print_l2_protection_fault_status(struct amdgpu_device *adev,
688688
status);
689689
switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
690690
case IP_VERSION(4, 2, 0):
691-
mmhub_cid = mmhub_client_ids_v4_2_0[cid][rw];
691+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v4_2_0) ?
692+
mmhub_client_ids_v4_2_0[cid][rw] : NULL;
692693
break;
693694
default:
694695
mmhub_cid = NULL;

0 commit comments

Comments
 (0)