]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/display: bridge_connector: get/put the stored bridges
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Fri, 26 Sep 2025 14:59:40 +0000 (16:59 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Fri, 3 Oct 2025 06:48:43 +0000 (08:48 +0200)
commit2be300f9a0b6f6b0ae2a90be97e558ec0535be54
tree967a83e3519548afdec1ab2d0a31f1166c858ae0
parent5b50bb435629ab206cfa1cca3d71847d4523f88b
drm/display: bridge_connector: get/put the stored bridges

drm_bridge_connector_init() takes eight pointers to various bridges, some
of which can be identical, and stores them in pointers inside struct
drm_bridge_connector. Get a reference to each of the taken bridges and put
it on cleanup.

This is tricky because the pointers are currently stored directly in the
drm_bridge_connector in the loop, but there is no nice and clean way to put
those pointers on error return paths. To overcome this, store all pointers
in temporary local variables with a cleanup action, and only on success
copy them into struct drm_bridge_connector (getting another ref while
copying).

Additionally four of these pointers (edid, hpd, detect and modes) can be
written in multiple loop iterations, in order to eventually store the last
matching bridge. However, when one of those pointers is overwritten, we
need to put the reference that we got during the previous assignment. Add a
drm_bridge_put() before writing them to handle this.

Finally, there is also a function-local panel_bridge pointer taken inside
the loop and used after the loop. Use a cleanup action as well to ensure it
is put on return.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250926-drm-bridge-alloc-getput-bridge-connector-v2-1-138b4bb70576@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/display/drm_bridge_connector.c