Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: fix memory leak in amdgpu_cs_sync_rings

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

authored by

Bert Karwatzki and committed by
Alex Deucher
9f8b3706 a3ee9e0b

+4 -1
+4 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 1220 1220 * next job actually sees the results from the previous one 1221 1221 * before we start executing on the same scheduler ring. 1222 1222 */ 1223 - if (!s_fence || s_fence->sched != sched) 1223 + if (!s_fence || s_fence->sched != sched) { 1224 + dma_fence_put(fence); 1224 1225 continue; 1226 + } 1225 1227 1226 1228 r = amdgpu_sync_fence(&p->gang_leader->explicit_sync, fence); 1229 + dma_fence_put(fence); 1227 1230 if (r) 1228 1231 return r; 1229 1232 }