Skip to content
/ linux Public

Commit 2a28ad5

Browse files
alexdeuchergregkh
authored andcommitted
drm/amdgpu/mmhub3.0: add bounds checking for cid
commit cdb82ec upstream. 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 f14f27bbe2a3ed7af32d5f6eaf3f417139f45253) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4641190 commit 2a28ad5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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 (adev->ip_versions[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)