]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/sched: Fix race in drm_sched_entity_select_rq()
authorPhilipp Stanner <phasta@kernel.org>
Mon, 3 Nov 2025 12:44:50 +0000 (07:44 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:01 +0000 (15:34 -0500)
[ Upstream commit d25e3a610bae03bffc5c14b5d944a5d0cd844678 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/scheduler/sched_entity.c

index 4a27e16b6265ec0ecc4a5c237c9ed751dc6275fe..261944cc4c3d0538f9ec449d57b893a2c0d9263f 100644 (file)
@@ -558,10 +558,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);
 }
 
 /**