]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu/mmhub2.3: add bounds checking for cid
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 4 Mar 2026 22:24:10 +0000 (17:24 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Mar 2026 16:18:46 +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 89cd90375c19fb45138990b70e9f4ba4806f05c4)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c

index 5eb8122e27469c1fc3b28a4ac79a96ba92a5ed55..ceb2f6b46de521a8080dcd7ac6f739819224f34b 100644 (file)
@@ -94,7 +94,8 @@ mmhub_v2_3_print_l2_protection_fault_status(struct amdgpu_device *adev,
        case IP_VERSION(2, 3, 0):
        case IP_VERSION(2, 4, 0):
        case IP_VERSION(2, 4, 1):
-               mmhub_cid = mmhub_client_ids_vangogh[cid][rw];
+               mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_vangogh) ?
+                       mmhub_client_ids_vangogh[cid][rw] : NULL;
                break;
        default:
                mmhub_cid = NULL;