]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu/mmhub4.2.0: add bounds checking for cid
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 4 Mar 2026 22:26:17 +0000 (17:26 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Mar 2026 14:49:47 +0000 (10:49 -0400)
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>
drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c

index 97a00075aa7aa21e1e5db29b3b53ef90d9870d82..2fb82e022c79bcf45f7a3206c63818a27b82e54d 100644 (file)
@@ -728,7 +728,8 @@ mmhub_v4_2_0_print_l2_protection_fault_status(struct amdgpu_device *adev,
                status);
        switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
        case IP_VERSION(4, 2, 0):
-               mmhub_cid = mmhub_client_ids_v4_2_0[cid][rw];
+               mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v4_2_0) ?
+                       mmhub_client_ids_v4_2_0[cid][rw] : NULL;
                break;
        default:
                mmhub_cid = NULL;