]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu/mmhub3.0.1: add bounds checking for cid
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 4 Mar 2026 22:24:35 +0000 (17:24 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Mar 2026 16:18:52 +0000 (12:18 -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 5f76083183363c4528a4aaa593f5d38c28fe7d7b)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c

index 910337dc28d10536f67cccabf14f56d815cd5e88..14a742d3a99d78735dea4b9f86c18fbbef5c230f 100644 (file)
@@ -117,7 +117,8 @@ mmhub_v3_0_1_print_l2_protection_fault_status(struct amdgpu_device *adev,
 
        switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
        case IP_VERSION(3, 0, 1):
-               mmhub_cid = mmhub_client_ids_v3_0_1[cid][rw];
+               mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v3_0_1) ?
+                       mmhub_client_ids_v3_0_1[cid][rw] : NULL;
                break;
        default:
                mmhub_cid = NULL;