drm/client: fix circular reference counting issue
authorChristian König <christian.koenig@amd.com>
Thu, 26 Jan 2023 09:24:26 +0000 (10:24 +0100)
committerChristian König <christian.koenig@amd.com>
Tue, 7 Feb 2023 08:42:56 +0000 (09:42 +0100)
commit85e26dd5100a182bf8448050427539c0a66ab793
tree6e83e2af7b4400316d53667e269db34f4a213f63
parent8f20660f053cefd4693e69cfff9cf58f4f7c4929
drm/client: fix circular reference counting issue

We reference dump buffers both by their handle as well as their
object. The problem is now that when anybody iterates over the DRM
framebuffers and exports the underlying GEM objects through DMA-buf
we run into a circular reference count situation.

The result is that the fbdev handling holds the GEM handle preventing
the DMA-buf in the GEM object to be released. This DMA-buf in turn
holds a reference to the driver module which on unload would release
the fbdev.

Break that loop by releasing the handle as soon as the DRM
framebuffer object is created. The DRM framebuffer and the DRM client
buffer structure still hold a reference to the underlying GEM object
preventing its destruction.

Signed-off-by: Christian König <christian.koenig@amd.com>
Fixes: c76f0f7cb546 ("drm: Begin an API for in-kernel clients")
Cc: <stable@vger.kernel.org>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Tested-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230126102814.8722-1-christian.koenig@amd.com
drivers/gpu/drm/drm_client.c
include/drm/drm_client.h