]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/bridge: get the bridge returned by drm_bridge_get_next_bridge()
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Fri, 1 Aug 2025 17:05:29 +0000 (19:05 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 16 Sep 2025 13:22:41 +0000 (15:22 +0200)
drm_bridge_get_next_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/20250801-drm-bridge-alloc-getput-drm_bridge_get_next_bridge-v2-7-888912b0be13@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
include/drm/drm_bridge.h

index d1aba4e25d354205d588480dc8032b969d92b912..0ff7ab4aa8689a022458f935a7ffb23a2b715802 100644 (file)
@@ -1362,6 +1362,13 @@ drm_bridge_get_current_state(struct drm_bridge *bridge)
  * drm_bridge_get_next_bridge() - Get the next bridge in the chain
  * @bridge: bridge object
  *
+ * The caller is responsible of having a reference to @bridge via
+ * drm_bridge_get() or equivalent. This function leaves the refcount of
+ * @bridge unmodified.
+ *
+ * The refcount of the returned bridge is incremented. Use drm_bridge_put()
+ * when done with it.
+ *
  * RETURNS:
  * the next bridge in the chain after @bridge, or NULL if @bridge is the last.
  */
@@ -1371,7 +1378,7 @@ drm_bridge_get_next_bridge(struct drm_bridge *bridge)
        if (list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain))
                return NULL;
 
-       return list_next_entry(bridge, chain_node);
+       return drm_bridge_get(list_next_entry(bridge, chain_node));
 }
 
 /**