@@ -204,6 +204,29 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *v
return vkms_config_connector;
}
+void vkms_config_disconnect_dev(struct vkms_config *vkms_config)
+{
+ struct vkms_config_connector *connector, *tmp_connector;
+ struct vkms_config_encoder *encoder, *tmp_encoder;
+ struct vkms_config_plane *plane, *tmp_plane;
+ struct vkms_config_crtc *crtc, *tmp_crtc;
+
+ vkms_config->dev = NULL;
+
+ list_for_each_entry_safe(connector, tmp_connector, &vkms_config->connectors, link) {
+ connector->connector = NULL;
+ }
+ list_for_each_entry_safe(encoder, tmp_encoder, &vkms_config->encoders, link) {
+ encoder->encoder = NULL;
+ }
+ list_for_each_entry_safe(plane, tmp_plane, &vkms_config->planes, link) {
+ plane->plane = NULL;
+ }
+ list_for_each_entry_safe(crtc, tmp_crtc, &vkms_config->crtcs, link) {
+ crtc->crtc = NULL;
+ }
+}
+
void vkms_config_connector_update_status(struct vkms_config_connector *vkms_config_connector,
enum drm_connector_status status)
{
@@ -117,10 +117,11 @@ struct vkms_config_connector {
char edid_blob[PAGE_SIZE];
int edid_blob_len;
- /* Internal usage */
+ /* Set only when the device is enabled */
struct drm_connector *connector;
};
+void vkms_config_disconnect_dev(struct vkms_config *vkms_config);
void vkms_config_connector_update_status(struct vkms_config_connector *vkms_config_connector,
enum drm_connector_status status);
@@ -242,7 +242,7 @@ void vkms_destroy(struct vkms_config *config)
devres_release_group(&pdev->dev, NULL);
platform_device_unregister(pdev);
- config->dev = NULL;
+ vkms_config_disconnect_dev(config);
}
static void __exit vkms_exit(void)
To avoid having dangling pointers in struct vkms_config, remove all of them when the device is destroyed. Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_config.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 3 ++- drivers/gpu/drm/vkms/vkms_drv.c | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-)