diff options
| author | Luca Ceresoli <luca.ceresoli@bootlin.com> | 2025-07-08 17:48:18 +0200 |
|---|---|---|
| committer | Luca Ceresoli <luca.ceresoli@bootlin.com> | 2025-07-22 13:01:28 +0200 |
| commit | 4d2d28776ae3ad7aa95328d28aff220b0ec6202d (patch) | |
| tree | 2ee62884d5083b4b26dfff1a9183ebc4994493f4 /rust/helpers/workqueue.c | |
| parent | ac6e050e69811c5c2057d519362c7b173a915542 (diff) | |
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>
Diffstat (limited to 'rust/helpers/workqueue.c')
0 files changed, 0 insertions, 0 deletions
