All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/gem: Fix a GEM leak in drm_gem_get_unmapped_area()
@ 2026-01-06 16:49 Boris Brezillon
  2026-01-07 11:12 ` Boris Brezillon
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Boris Brezillon @ 2026-01-06 16:49 UTC (permalink / raw)
  To: dri-devel, David Airlie, Simona Vetter, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann
  Cc: Boris Brezillon, kernel, Loïc Molinari

drm_gem_object_lookup_at_offset() can return a valid object with
filp or filp->f_op->get_unmapped_area set to NULL. Make sure we still
release the ref we acquired on such objects.

Cc: Loïc Molinari <loic.molinari@collabora.com>
Fixes: 99bda20d6d4c ("drm/gem: Introduce drm_gem_get_unmapped_area() fop")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 drivers/gpu/drm/drm_gem.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 36c8af123877..f7cbf6e8d1e0 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1298,11 +1298,13 @@ unsigned long drm_gem_get_unmapped_area(struct file *filp, unsigned long uaddr,
 	unsigned long ret;
 
 	obj = drm_gem_object_lookup_at_offset(filp, pgoff, len >> PAGE_SHIFT);
-	if (IS_ERR(obj) || !obj->filp || !obj->filp->f_op->get_unmapped_area)
-		return mm_get_unmapped_area(filp, uaddr, len, 0, flags);
+	if (IS_ERR(obj))
+		obj = NULL;
 
-	ret = obj->filp->f_op->get_unmapped_area(obj->filp, uaddr, len, 0,
-						 flags);
+	if (!obj || !obj->filp || !obj->filp->f_op->get_unmapped_area)
+		ret = mm_get_unmapped_area(filp, uaddr, len, 0, flags);
+	else
+		ret = obj->filp->f_op->get_unmapped_area(obj->filp, uaddr, len, 0, flags);
 
 	drm_gem_object_put(obj);
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-01-09 12:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-06 16:49 [PATCH] drm/gem: Fix a GEM leak in drm_gem_get_unmapped_area() Boris Brezillon
2026-01-07 11:12 ` Boris Brezillon
2026-01-08 13:25   ` Loïc Molinari
2026-01-08 13:43     ` Boris Brezillon
2026-01-08 14:04       ` Loïc Molinari
2026-01-08 14:45         ` Boris Brezillon
2026-01-09  9:42           ` Loïc Molinari
2026-01-09  9:50             ` Boris Brezillon
2026-01-08 13:18 ` Loïc Molinari
2026-01-08 13:31   ` Boris Brezillon
2026-01-08 14:09     ` Loïc Molinari
2026-01-09 12:02 ` Boris Brezillon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.