Subject: [PATCH 17/37] drm/display: bridge-connector: protect dynconn creation and destruction with a mutex

From: Luca Ceresoli <[email-masked]>
Date: Tue, 19 May 2026 12:37:34 +0200

Bridge hotplug will make the connector dynamically created and destroyed
based on hotplug events.

In preparation for that, add a mutex to mutually exclude connector creation
and destruction.

Signed-off-by: Luca Ceresoli <[email-masked]>
---
 drivers/gpu/drm/display/drm_bridge_connector.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/drm/display/drm_bridge_connector.c
index bd421b6beb7c..b83da529cc7a 100644
--- a/drivers/gpu/drm/display/drm_bridge_connector.c
+++ b/drivers/gpu/drm/display/drm_bridge_connector.c
@@ -8,6 +8,7 @@
 #include <linux/export.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/property.h>
 #include <linux/slab.h>
@@ -152,6 +153,11 @@ struct drm_bridge_connector {
 	 * @dynconn: The DRM connector added by the drm_bridge_connector
 	 */
 	struct drm_bridge_connector_dynconn *dynconn;
+	/**
+	 * @dynconn_mutex: Protect @dynconn from concurrent creation and
+	 * destruction
+	 */
+	struct mutex dynconn_mutex;
 };
 
 static struct drm_bridge_connector_dynconn *
@@ -810,6 +816,8 @@ static const struct drm_connector_hdmi_cec_funcs drm_bridge_connector_hdmi_cec_f
 
 static void drm_bridge_connector_dynconn_release(struct drm_bridge_connector *bridge_connector)
 {
+	guard(mutex)(&bridge_connector->dynconn_mutex);
+
 	if (!bridge_connector->dynconn)
 		return;
 
@@ -1050,6 +1058,8 @@ static int drm_bridge_connector_add_connector(struct drm_bridge_connector *bridg
 	int connector_type;
 	int ret;
 
+	guard(mutex)(&bridge_connector->dynconn_mutex);
+
 	struct drm_bridge_connector_dynconn *dynconn = kzalloc_obj(*dynconn);
 	if (!dynconn)
 		return -ENOMEM;
@@ -1177,6 +1187,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 	if (!bridge_connector)
 		return ERR_PTR(-ENOMEM);
 
+	mutex_init(&bridge_connector->dynconn_mutex);
 	bridge_connector->drm = drm;
 	bridge_connector->encoder = encoder;

-- 
2.54.0