[PATCH RFC v2 02/16] drm/vkms: Cleanup configuration field on device destroy
Louis Chauvet
louis.chauvet at bootlin.com
Fri Nov 22 17:38:28 UTC 2024
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 at 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(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 26280ad223208a978c44ef9c6c6eaadf1756818d..9a461a0481c2a20d6d48f1aa9649843ad1b7d13d 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -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)
{
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index c6fe0573abd899e4b44b5ad390ff72e12664973f..529d9c99f3c406d49dc7f3689a84c3dd775399a9 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -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);
diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index 2db393f5782eb26a5aa469a4774b2e19c886ee7e..8ffbd5fc65350ba03f870726b669d189f62bad6f 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -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)
--
2.47.0
More information about the dri-devel
mailing list