Skip to content

Commit 6a04464

Browse files
committed
drm/meson: fix unbind path if HDMI fails to bind
If the case the HDMI controller fails to bind, we try to unbind all components before calling drm_dev_put() which makes drm_bridge_detach() crash because unbinding the HDMI controller frees the bridge memory. The solution is the unbind all components at the end like in the remove path. Reviewed-by: Nicolas Belin <nbelin@baylibre.com> Tested-by: Nicolas Belin <nbelin@baylibre.com> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230512-amlogic-v6-4-upstream-dsi-ccf-vim3-v5-8-56eb7a4d5b8e@linaro.org
1 parent 25b3b35 commit 6a04464

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

drivers/gpu/drm/meson/meson_drv.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,32 +316,34 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
316316
goto exit_afbcd;
317317

318318
if (has_components) {
319-
ret = component_bind_all(drm->dev, drm);
319+
ret = component_bind_all(dev, drm);
320320
if (ret) {
321321
dev_err(drm->dev, "Couldn't bind all components\n");
322+
/* Do not try to unbind */
323+
has_components = false;
322324
goto exit_afbcd;
323325
}
324326
}
325327

326328
ret = meson_encoder_hdmi_init(priv);
327329
if (ret)
328-
goto unbind_all;
330+
goto exit_afbcd;
329331

330332
ret = meson_plane_create(priv);
331333
if (ret)
332-
goto unbind_all;
334+
goto exit_afbcd;
333335

334336
ret = meson_overlay_create(priv);
335337
if (ret)
336-
goto unbind_all;
338+
goto exit_afbcd;
337339

338340
ret = meson_crtc_create(priv);
339341
if (ret)
340-
goto unbind_all;
342+
goto exit_afbcd;
341343

342344
ret = request_irq(priv->vsync_irq, meson_irq, 0, drm->driver->name, drm);
343345
if (ret)
344-
goto unbind_all;
346+
goto exit_afbcd;
345347

346348
drm_mode_config_reset(drm);
347349

@@ -359,15 +361,18 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
359361

360362
uninstall_irq:
361363
free_irq(priv->vsync_irq, drm);
362-
unbind_all:
363-
if (has_components)
364-
component_unbind_all(drm->dev, drm);
365364
exit_afbcd:
366365
if (priv->afbcd.ops)
367366
priv->afbcd.ops->exit(priv);
368367
free_drm:
369368
drm_dev_put(drm);
370369

370+
meson_encoder_hdmi_remove(priv);
371+
meson_encoder_cvbs_remove(priv);
372+
373+
if (has_components)
374+
component_unbind_all(dev, drm);
375+
371376
return ret;
372377
}
373378

0 commit comments

Comments
 (0)