Skip to content

Commit 3cdd405

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

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ mmhub_v4_1_0_print_l2_protection_fault_status(struct amdgpu_device *adev,
102102
status);
103103
switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
104104
case IP_VERSION(4, 1, 0):
105-
mmhub_cid = mmhub_client_ids_v4_1_0[cid][rw];
105+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v4_1_0) ?
106+
mmhub_client_ids_v4_1_0[cid][rw] : NULL;
106107
break;
107108
default:
108109
mmhub_cid = NULL;

0 commit comments

Comments
 (0)