]> Gentwo Git Trees - linux/.git/commit
drm/bridge: add a cleanup action for scope-based drm_bridge_put() invocation
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 8 Jul 2025 15:48:18 +0000 (17:48 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 22 Jul 2025 11:01:28 +0000 (13:01 +0200)
commit4d2d28776ae3ad7aa95328d28aff220b0ec6202d
tree2ee62884d5083b4b26dfff1a9183ebc4994493f4
parentac6e050e69811c5c2057d519362c7b173a915542
drm/bridge: add a cleanup action for scope-based drm_bridge_put() invocation

Many functions get a drm_bridge pointer, only use it in the function body
(or a smaller scope such as a loop body), and don't store it. In these
cases they always need to drm_bridge_put() it before returning (or exiting
the scope).

Some of those functions have complex code paths with multiple return points
or loop break/continue. This makes adding drm_bridge_put() in the right
places tricky, ugly and error prone in case of future code changes.

Others use the bridge pointer in the return statement and would need to
split the return line to fit the drm_bridge_put, which is a bit annoying:

  -return some_thing(bridge);
  +ret = some_thing(bridge);
  +drm_bridge_put(bridge);
  +return ret;

To make it easier for all of them to put the bridge reference correctly
without complicating code, define a scope-based cleanup action to be used
with __free().

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-1-db1ba3df7f58@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
include/drm/drm_bridge.h