From: Luca Ceresoli Date: Tue, 8 Jul 2025 15:48:19 +0000 (+0200) Subject: drm/bridge: get the bridge returned by drm_bridge_chain_get_first_bridge() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8fa5909400f377351836419223c33f1131f0f7d3;p=users%2Fhch%2Fmisc.git drm/bridge: get the bridge returned by drm_bridge_chain_get_first_bridge() 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 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 --- diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 8290e665554e..717171d0e587 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -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)); } /**