linux/drivers/gpu/drm/ingenic
Albert Esteve b71a623598 drm/panel: of_drm_find_panel() return a counted reference
Callers of of_drm_find_panel() and drm_of_find_panel_or_bridge()
receive a pointer with no reference held, creating a window where
the panel device can be unregistered and freed between the lookup
and first use (e.g., drm_panel_prepare()).

Fix the lookup function by acquiring a reference with drm_panel_get()
before returning, under panel_lock. Callers are now responsible for
calling drm_panel_put() when they no longer need the pointer.

For bridge drivers that immediately wrap the panel in a panel_bridge
(which acquires its own reference), release the lookup reference right
after the bridge creation call.

For analogix-anx6345, which stores the panel for direct use, release
the reference in the i2c remove path.

For platform drivers using analogix_dp_core with a component lifecycle
(exynos_dp, rockchip analogix_dp), release the lookup reference in the
platform remove() function. The panel_bridge created during bind() holds
a separate reference that devm cleanup releases after remove() returns.

Also fix devm_drm_of_get_bridge() and drmm_of_get_bridge() in
bridge/panel.c itself, update a second batch of drivers calling
of_drm_find_panel() or drm_of_find_panel_or_bridge() to release the
lookup reference after wrapping the panel in a bridge, and handle the
cases where a panel is found but cannot be used, dropping the reference
immediately in those paths.

Assisted-by: Claude:claude-opus-4-6
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20260717-drm_refcount_wiring-v3-3-023900c32e01@redhat.com
2026-07-20 15:07:22 +02:00
..
ingenic-drm-drv.c drm/panel: of_drm_find_panel() return a counted reference 2026-07-20 15:07:22 +02:00
ingenic-drm.h drm/ingenic: Use the highest possible DMA burst size 2022-07-04 14:03:54 +01:00
ingenic-dw-hdmi.c drm/ingenic: Add dw-hdmi driver specialization for jz4780 2022-04-11 16:04:39 +01:00
ingenic-ipu.c drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
ingenic-ipu.h
Kconfig drm/ingenic: Run DRM default client setup 2024-09-26 08:28:03 +02:00
Makefile drm/ingenic: Add dw-hdmi driver specialization for jz4780 2022-04-11 16:04:39 +01:00