]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/msm: Fix another leak in the submit error path
authorRob Clark <robdclark@chromium.org>
Wed, 14 May 2025 16:33:33 +0000 (09:33 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Jul 2025 14:05:06 +0000 (16:05 +0200)
[ Upstream commit f681c2aa8676a890eacc84044717ab0fd26e058f ]

put_unused_fd() doesn't free the installed file, if we've already done
fd_install().  So we need to also free the sync_file.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/653583/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/msm/msm_gem_submit.c

index 937c1f5d88cbbc9789117d5bac76c19cd646c88e..4b3a8ee8e278f09647f350303ad054f35e49e9fc 100644 (file)
@@ -667,6 +667,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        struct msm_ringbuffer *ring;
        struct msm_submit_post_dep *post_deps = NULL;
        struct drm_syncobj **syncobjs_to_reset = NULL;
+       struct sync_file *sync_file = NULL;
        int out_fence_fd = -1;
        unsigned i;
        int ret;
@@ -877,7 +878,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        }
 
        if (ret == 0 && args->flags & MSM_SUBMIT_FENCE_FD_OUT) {
-               struct sync_file *sync_file = sync_file_create(submit->user_fence);
+               sync_file = sync_file_create(submit->user_fence);
                if (!sync_file) {
                        ret = -ENOMEM;
                } else {
@@ -911,8 +912,11 @@ out:
 out_unlock:
        mutex_unlock(&queue->lock);
 out_post_unlock:
-       if (ret && (out_fence_fd >= 0))
+       if (ret && (out_fence_fd >= 0)) {
                put_unused_fd(out_fence_fd);
+               if (sync_file)
+                       fput(sync_file->file);
+       }
 
        if (!IS_ERR_OR_NULL(submit)) {
                msm_gem_submit_put(submit);