Skip to content
/ linux Public

Commit 7687403

Browse files
alexdeuchergregkh
authored andcommitted
drm/amdgpu/mmhub4.1.0: add bounds checking for cid
commit 3cdd405 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 04f063d85090f5dd0c671010ce88ee49d9dcc8ed) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 72365be commit 7687403

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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)