]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/bridge: get the bridge returned by drm_bridge_get_prev_bridge()
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 9 Jul 2025 15:59:37 +0000 (17:59 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 23 Jul 2025 11:03:53 +0000 (13:03 +0200)
drm_bridge_get_prev_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/20250709-drm-bridge-alloc-getput-drm_bridge_get_prev_bridge-v1-1-34ba6f395aaa@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
include/drm/drm_bridge.h

index 717171d0e58725ed854209c3355260e415b4c5d7..620e119cc24c3491c2be5f08efaf51dfa8f708b3 100644 (file)
@@ -1321,6 +1321,13 @@ drm_bridge_get_next_bridge(struct drm_bridge *bridge)
  * drm_bridge_get_prev_bridge() - Get the previous 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 previous bridge in the chain, or NULL if @bridge is the first.
  */
@@ -1330,7 +1337,7 @@ drm_bridge_get_prev_bridge(struct drm_bridge *bridge)
        if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain))
                return NULL;
 
-       return list_prev_entry(bridge, chain_node);
+       return drm_bridge_get(list_prev_entry(bridge, chain_node));
 }
 
 /**