]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amdgpu: fix memory leak in amdgpu_cs_sync_rings
authorBert Karwatzki <spasswolf@web.de>
Thu, 2 Feb 2023 19:02:36 +0000 (20:02 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 3 Feb 2023 19:21:31 +0000 (14:21 -0500)
amdgpu_sync_get_fence deletes the returned fence from the
syncobj, so the refcount of fence needs to lowered to avoid
a memory leak.

Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2360
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Bert Karwatzki <spasswolf@web.de>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/3b590ba0f11d24b8c6c39c3d38250129c1116af4.camel@web.de
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

index 7b5ce00f060260114a0421cf47905e7a009a945c..7af3041ccd0e8289d76e50ff46121889209f1f37 100644 (file)
@@ -1220,10 +1220,13 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
                 * next job actually sees the results from the previous one
                 * before we start executing on the same scheduler ring.
                 */
-               if (!s_fence || s_fence->sched != sched)
+               if (!s_fence || s_fence->sched != sched) {
+                       dma_fence_put(fence);
                        continue;
+               }
 
                r = amdgpu_sync_fence(&p->gang_leader->explicit_sync, fence);
+               dma_fence_put(fence);
                if (r)
                        return r;
        }