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

drm/syncobj: Don't leak fences when WAIT_FOR_SUBMIT is set

We attempt to get fences earlier in the hopes that everything will
already have fences and no callbacks will be needed. If we do succeed
in getting a fence, getting one a second time will result in a duplicate
ref with no unref. This is causing memory leaks in Vulkan applications
that create a lot of fences; playing for a few hours can, apparently,
bring down the system.

Cc: stable@vger.kernel.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20180926071703.15257-1-jason.ekstrand@intel.com

authored by

Jason Ekstrand and committed by
Sean Paul
337fe9f5 6bf4ca7f

+5
+5
drivers/gpu/drm/drm_syncobj.c
··· 97 97 { 98 98 int ret; 99 99 100 + WARN_ON(*fence); 101 + 100 102 *fence = drm_syncobj_fence_get(syncobj); 101 103 if (*fence) 102 104 return 1; ··· 745 743 746 744 if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) { 747 745 for (i = 0; i < count; ++i) { 746 + if (entries[i].fence) 747 + continue; 748 + 748 749 drm_syncobj_fence_get_or_add_callback(syncobjs[i], 749 750 &entries[i].fence, 750 751 &entries[i].syncobj_cb,