Skip to contentSkip to conversation

drm/rockchip: dw_hdmi: cleanup drm encoder during unbind

PATCH Applied Toby Chen 2 participants 2 messages Mar 17, 2023 – Mar 22, 2023

Subsystems (4)
lore
Share & tools
lore

Toby Chen

author
#0 lore raw

PATCH 1/1 drm/rockchip: dw_hdmi: cleanup drm encoder during unbind

This fixes a use-after-free crash during rmmod.

The DRM encoder is embedded inside the larger rockchip_hdmi, which is allocated with the component. The component memory gets freed before the main drm device is destroyed. Fix it by running encoder cleanup before tearing down its container.

---
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +2 -0
index 2f4b8f64cbad..8aa88e6c9e5a 100644
@@ -642,6 +642,8 @@ static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master,
 	dw_hdmi_unbind(hdmi->hdmi);
 	clk_disable_unprepare(hdmi->ref_clk);
 
+	drm_encoder_cleanup(&hdmi->encoder.encoder);
+
 	regulator_disable(hdmi->avdd_1v8);
 	regulator_disable(hdmi->avdd_0v9);
 }
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Toby Chen

This fixes a use-after-free crash during rmmod.

The DRM encoder is embedded inside the larger rockchip_hdmi, which is allocated with the component. The component memory gets freed before the main drm device is destroyed. Fix it by running encoder cleanup before tearing down its container.

[...]

Applied, thanks!

[1/1] drm/rockchip: dw_hdmi: cleanup drm encoder during unbind

      commit: b5af48eedcb53491c02ded55d5991e03d6da6dbf

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>