Attaching CRTC to a connector increases its reference count, preventing
it from correct deinitialization. Following kernel log is printed when
the leak is found:

        Console: switching to colour VGA+ 80x25
        WARNING: at drivers/gpu/drm/drm_mode_config.c:431
        ...
        Call Trace:
         drm_mode_config_cleanup
         virtio_gpu_modeset_fini
         virtio_gpu_driver_unload
         drm_dev_unregister
         drm_put_dev
         virtio_gpu_remove
         virtio_dev_remove
         device_release_driver_internal
         device_release_driver
         bus_remove_device
         device_del
         device_unregister
         unregister_virtio_device
        ...
        [drm:drm_mode_config_cleanup] ERROR connector Virtual-1 leaked!

Calling drm_atomic_helper_shutdown disconnects CRTCs from connectors,
allowing them to be freed during drm_mode_config_cleanup.

Signed-off-by: Damir Shaikhutdinov <[email protected]>
Signed-off-by: Kiran Pawar <[email protected]>
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c 
b/drivers/gpu/drm/virtio/virtgpu_display.c
index d314e3c672f2..088a751a35e9 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -377,5 +377,6 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev)
 
 void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev)
 {
+       drm_atomic_helper_shutdown(vgdev->ddev);
        drm_mode_config_cleanup(vgdev->ddev);
 }
-- 
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to