]> git.ipfire.org Git - thirdparty/kernel/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 16:19:17 +0000 (12:19 -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>
(cherry picked from commit dea5f235baf3786bfd4fd920b03c19285fdc3d9f)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c

index a72770e3d0e997d354db9507c82333c2859ab3da..2532ca80f7356095c3796c1d12bbee48d03699c1 100644 (file)
@@ -688,7 +688,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;