]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu: Fix out-of-bounds write warning
authorMa Jun <Jun.Ma2@amd.com>
Thu, 25 Apr 2024 06:00:17 +0000 (14:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Sep 2024 09:06:40 +0000 (11:06 +0200)
[ Upstream commit be1684930f5262a622d40ce7a6f1423530d87f89 ]

Check the ring type value to fix the out-of-bounds
write warning

Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
Suggested-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Tim Huang <Tim.Huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

index 6976f61be7341d2241bb161f86acb6604db62a2a..b78feb8ba01e13ac075a4579e29ea7eef831434a 100644 (file)
@@ -260,7 +260,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
        ring->priority = DRM_SCHED_PRIORITY_NORMAL;
        mutex_init(&ring->priority_mutex);
 
-       if (!ring->no_scheduler) {
+       if (!ring->no_scheduler && ring->funcs->type < AMDGPU_HW_IP_NUM) {
                hw_ip = ring->funcs->type;
                num_sched = &adev->gpu_sched[hw_ip][hw_prio].num_scheds;
                adev->gpu_sched[hw_ip][hw_prio].sched[(*num_sched)++] =