drm/bridge: aux-hpd: separate allocation and registration
authorJohan Hovold <johan+linaro@kernel.org>
Sat, 17 Feb 2024 15:02:24 +0000 (16:02 +0100)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Fri, 23 Feb 2024 15:00:56 +0000 (17:00 +0200)
commite5ca263508f7e9d2cf711edf3258d11ca087885c
tree3084c6c0188c02c757fb2946b4e440b55266c6a5
parent9ee485bdda68d6d3f5728cbe3150eb9013d7d22b
drm/bridge: aux-hpd: separate allocation and registration

Combining allocation and registration is an anti-pattern that should be
avoided. Add two new functions for allocating and registering an dp-hpd
bridge with a proper 'devm' prefix so that it is clear that these are
device managed interfaces.

devm_drm_dp_hpd_bridge_alloc()
devm_drm_dp_hpd_bridge_add()

The new interface will be used to fix a use-after-free bug in the
Qualcomm PMIC GLINK driver and may prevent similar issues from being
introduced elsewhere.

The existing drm_dp_hpd_bridge_register() is reimplemented using the
above and left in place for now.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240217150228.5788-3-johan+linaro@kernel.org
drivers/gpu/drm/bridge/aux-hpd-bridge.c
include/drm/bridge/aux-bridge.h