]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/syncobj: Fix memory leak in drm_syncobj_find_fence()
authorLiviu Dudau <liviu.dudau@arm.com>
Thu, 7 May 2026 10:50:46 +0000 (11:50 +0100)
committerLiviu Dudau <liviu.dudau@arm.com>
Mon, 18 May 2026 10:19:59 +0000 (11:19 +0100)
Commit 18226ba52159 ("drm/syncobj: reject invalid flags in
drm_syncobj_find_fence") forgot to take into account the fact that
drm_syncobj_find() takes a reference to syncobj and returns early
without dropping the reference, leading to memory leaks.

Fixes: 18226ba52159 ("drm/syncobj: reject invalid flags in drm_syncobj_find_fence")
Reported by: Sam Spencer <sam.spencer@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Acked-by: Erik Kurzinger <ekurzinger@gmail.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://lore.kernel.org/all/20260507144425.2488057-1-liviu.dudau@arm.com
drivers/gpu/drm/drm_syncobj.c

index 8d9fd1917c6e64e1331b940388f70515a76a4926..c9dbf64c0c9f2cb7836897ed07857ef2a9411f62 100644 (file)
@@ -442,13 +442,15 @@ int drm_syncobj_find_fence(struct drm_file *file_private,
        u64 timeout = nsecs_to_jiffies64(DRM_SYNCOBJ_WAIT_FOR_SUBMIT_TIMEOUT);
        int ret;
 
-       if (flags & ~DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT)
-               return -EINVAL;
-
        if (!syncobj)
                return -ENOENT;
 
-       /* Waiting for userspace with locks help is illegal cause that can
+       if (flags & ~DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       /* Waiting for userspace with locks held is illegal cause that can
         * trivial deadlock with page faults for example. Make lockdep complain
         * about it early on.
         */