Skip to content

Commit f39e127

Browse files
committed
drm/amdgpu/gmc9.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. Cc: Benjamin Cheng <benjamin.cheng@amd.com> Reviewed-by: Benjamin Cheng <benjamin.cheng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit e14d468) Cc: stable@vger.kernel.org
1 parent 9c52f49 commit f39e127

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -662,28 +662,35 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
662662
} else {
663663
switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
664664
case IP_VERSION(9, 0, 0):
665-
mmhub_cid = mmhub_client_ids_vega10[cid][rw];
665+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_vega10) ?
666+
mmhub_client_ids_vega10[cid][rw] : NULL;
666667
break;
667668
case IP_VERSION(9, 3, 0):
668-
mmhub_cid = mmhub_client_ids_vega12[cid][rw];
669+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_vega12) ?
670+
mmhub_client_ids_vega12[cid][rw] : NULL;
669671
break;
670672
case IP_VERSION(9, 4, 0):
671-
mmhub_cid = mmhub_client_ids_vega20[cid][rw];
673+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_vega20) ?
674+
mmhub_client_ids_vega20[cid][rw] : NULL;
672675
break;
673676
case IP_VERSION(9, 4, 1):
674-
mmhub_cid = mmhub_client_ids_arcturus[cid][rw];
677+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_arcturus) ?
678+
mmhub_client_ids_arcturus[cid][rw] : NULL;
675679
break;
676680
case IP_VERSION(9, 1, 0):
677681
case IP_VERSION(9, 2, 0):
678-
mmhub_cid = mmhub_client_ids_raven[cid][rw];
682+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_raven) ?
683+
mmhub_client_ids_raven[cid][rw] : NULL;
679684
break;
680685
case IP_VERSION(1, 5, 0):
681686
case IP_VERSION(2, 4, 0):
682-
mmhub_cid = mmhub_client_ids_renoir[cid][rw];
687+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_renoir) ?
688+
mmhub_client_ids_renoir[cid][rw] : NULL;
683689
break;
684690
case IP_VERSION(1, 8, 0):
685691
case IP_VERSION(9, 4, 2):
686-
mmhub_cid = mmhub_client_ids_aldebaran[cid][rw];
692+
mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_aldebaran) ?
693+
mmhub_client_ids_aldebaran[cid][rw] : NULL;
687694
break;
688695
default:
689696
mmhub_cid = NULL;

0 commit comments

Comments
 (0)