]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/sched: Fix race in drm_sched_entity_select_rq()
authorPhilipp Stanner <phasta@kernel.org>
Wed, 22 Oct 2025 06:34:03 +0000 (08:34 +0200)
committerPhilipp Stanner <phasta@kernel.org>
Mon, 27 Oct 2025 12:48:46 +0000 (13:48 +0100)
In a past bug fix it was forgotten that entity access must be protected
by the entity lock. That's a data race and potentially UB.

Move the spin_unlock() to the appropriate position.

Cc: stable@vger.kernel.org # v5.13+
Fixes: ac4eb83ab255 ("drm/sched: select new rq even if there is only one v3")
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patch.msgid.link/20251022063402.87318-2-phasta@kernel.org
drivers/gpu/drm/scheduler/sched_entity.c

index 5a4697f636f2d7957a5b0b0c792d39aca996f983..aa222166de580bb3b49503b62506d1b4f611ced3 100644 (file)
@@ -552,10 +552,11 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
                drm_sched_rq_remove_entity(entity->rq, entity);
                entity->rq = rq;
        }
-       spin_unlock(&entity->lock);
 
        if (entity->num_sched_list == 1)
                entity->sched_list = NULL;
+
+       spin_unlock(&entity->lock);
 }
 
 /**