Skip to contentSkip to conversation

drm/sun4i: dsi: Avoid hotplug race with DRM driver bind

PATCH In review Samuel Holland 2 participants 2 messages Feb 17, 2020 – Feb 19, 2020

Subsystems (5)
lore
Share & tools
lore

Samuel Holland

author maintainer
#0 lore raw

PATCH 1/1 drm/sun4i: dsi: Avoid hotplug race with DRM driver bind

We need to make sure that the DRM driver is fully registered before allowing the panel to be attached. Otherwise, we may trigger a hotplug event before sun4i_framebuffer_init() sets up drm->mode_config.funcs, causing a NULL pointer dereference.

Fixes 1a2703bd7356 ("drm/sun4i: dsi: Allow binding the host without a panel")

---

This fixes a bug in my previous patch series, that I didn't catch until it was already merged.

---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +1 -1
index 9aa78c73873c..9cc1bb69fcda 100644
@@ -970,7 +970,7 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host,
 
 	if (IS_ERR(panel))
 		return PTR_ERR(panel);
-	if (!dsi->drm)
+	if (!dsi->drm || !dsi->drm->registered)
 		return -EPROBE_DEFER;
 
 	dsi->panel = panel;
Signature · 1 line
2.24.1
#1 lore raw
Quoted 7 lines · Samuel Holland

We need to make sure that the DRM driver is fully registered before allowing the panel to be attached. Otherwise, we may trigger a hotplug event before sun4i_framebuffer_init() sets up drm->mode_config.funcs, causing a NULL pointer dereference.

Fixes 1a2703bd7356 ("drm/sun4i: dsi: Allow binding the host without a panel")

Thanks for following up on this, I've applied it

Maxime