Commit e064cef4 authored by Alex Deucher's avatar Alex Deucher
Browse files

drm/amdgpu/mmhub2.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: default avatarBenjamin Cheng <benjamin.cheng@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e6020a55
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -154,14 +154,17 @@ mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev,
	switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
	case IP_VERSION(2, 0, 0):
	case IP_VERSION(2, 0, 2):
		mmhub_cid = mmhub_client_ids_navi1x[cid][rw];
		mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_navi1x) ?
			mmhub_client_ids_navi1x[cid][rw] : NULL;
		break;
	case IP_VERSION(2, 1, 0):
	case IP_VERSION(2, 1, 1):
		mmhub_cid = mmhub_client_ids_sienna_cichlid[cid][rw];
		mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_sienna_cichlid) ?
			mmhub_client_ids_sienna_cichlid[cid][rw] : NULL;
		break;
	case IP_VERSION(2, 1, 2):
		mmhub_cid = mmhub_client_ids_beige_goby[cid][rw];
		mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_beige_goby) ?
			mmhub_client_ids_beige_goby[cid][rw] : NULL;
		break;
	default:
		mmhub_cid = NULL;