]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/bridge: get the bridge returned by drm_bridge_chain_get_first_bridge()
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 8 Jul 2025 15:48:19 +0000 (17:48 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 22 Jul 2025 11:01:28 +0000 (13:01 +0200)
drm_bridge_chain_get_first_bridge() returns a bridge pointer that the
caller could hold for a long time. Increment the refcount of the returned
bridge and document it must be put by the caller.

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20250708-drm-bridge-alloc-getput-drm_bridge_chain_get_first_bridge-v9-2-db1ba3df7f58@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
include/drm/drm_bridge.h

index 8290e665554ebcc321085cc069473c4642451133..717171d0e58725ed854209c3355260e415b4c5d7 100644 (file)
@@ -1337,6 +1337,9 @@ drm_bridge_get_prev_bridge(struct drm_bridge *bridge)
  * drm_bridge_chain_get_first_bridge() - Get the first bridge in the chain
  * @encoder: encoder object
  *
+ * The refcount of the returned bridge is incremented. Use drm_bridge_put()
+ * when done with it.
+ *
  * RETURNS:
  * the first bridge in the chain, or NULL if @encoder has no bridge attached
  * to it.
@@ -1344,8 +1347,8 @@ drm_bridge_get_prev_bridge(struct drm_bridge *bridge)
 static inline struct drm_bridge *
 drm_bridge_chain_get_first_bridge(struct drm_encoder *encoder)
 {
-       return list_first_entry_or_null(&encoder->bridge_chain,
-                                       struct drm_bridge, chain_node);
+       return drm_bridge_get(list_first_entry_or_null(&encoder->bridge_chain,
+                                                      struct drm_bridge, chain_node));
 }
 
 /**