[PATCH] drm/gem: Fix ww_acquire context leak in drm_gem_lru_scan()
From: yaolu
Date: Mon Jun 08 2026 - 22:44:00 EST
From: Lu Yao <yaolu@xxxxxxxxxx>
When ww_mutex_trylock() fails, the code jumps to the 'tail'
label, skipping the ww_acquire_fini() call that normally
follows. This leaks the ww_acquire context initialized by
ww_acquire_init().
Fix by moving ww_acquire_fini() into the 'tail' label section.
Fixes: 02070f049875 ("drm/gem: Add ww_acquire_ctx support to drm_gem_lru_scan()")
Signed-off-by: Lu Yao <yaolu@xxxxxxxxxx>
---
drivers/gpu/drm/drm_gem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 6568fbdc4641..575a26ca9ca3 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1722,10 +1722,10 @@ drm_gem_lru_scan(struct drm_device *dev,
dma_resv_unlock(obj->resv);
+tail:
if (ticket)
ww_acquire_fini(ticket);
-tail:
drm_gem_object_put(obj);
mutex_lock(&dev->gem_lru_mutex);
}
--
2.25.1