#include "vkms_drv.h"
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_managed.h>
 #include <drm/drm_probe_helper.h>
 
 static const struct drm_connector_funcs vkms_connector_funcs = {
        .fill_modes = drm_helper_probe_single_connector_modes,
-       .destroy = drm_connector_cleanup,
        .reset = drm_atomic_helper_connector_reset,
        .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
                }
        }
 
-       ret = drm_connector_init(dev, connector, &vkms_connector_funcs,
-                                DRM_MODE_CONNECTOR_VIRTUAL);
+       ret = drmm_connector_init(dev, connector, &vkms_connector_funcs,
+                                 DRM_MODE_CONNECTOR_VIRTUAL, NULL);
        if (ret) {
                DRM_ERROR("Failed to init connector\n");
                return ret;
                               DRM_MODE_ENCODER_VIRTUAL, NULL);
        if (ret) {
                DRM_ERROR("Failed to init encoder\n");
-               goto err_encoder;
+               return ret;
        }
        encoder->possible_crtcs = drm_crtc_mask(crtc);
 
 
 err_attach:
        drm_encoder_cleanup(encoder);
-
-err_encoder:
-       drm_connector_cleanup(connector);
-
        return ret;
 }