The hdlcd_probe() error paths for pm_runtime_set_active() and
drm_vblank_init() fall through to the err_pm_active label, which calls
drm_atomic_helper_shutdown().
However, both calls happen before drm_mode_config_reset(), so the CRTC
state is still NULL at that point. drm_atomic_helper_shutdown() will
then go through drm_atomic_helper_disable_all() and
drm_atomic_get_crtc_state() to drm_atomic_helper_crtc_duplicate_state(),
which trips its WARN_ON(!crtc->state) and returns an error.
Move drm_atomic_helper_shutdown() to the err_register label, the only
error path where drm_mode_config_reset() has run and thus where
shutting the device down makes sense. This also brings the error path
closer to hdlcd_remove(), which calls drm_atomic_helper_shutdown()
while runtime PM is still enabled.
The pm_runtime_set_active() error path now jumps directly to
err_unload: runtime PM hasn't been enabled at that point, so calling
pm_runtime_disable() there wasn't needed either.
It will also be needed when drm_mode_config_reset() gets replaced by
drm_mode_config_create_initial_state(), whose state allocation can
fail.
Fixes: d664b851eb2bc ("drm/arm/hdlcd: Reject atomic commits that disable only
the plane")
Reported-by: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Maxime Ripard <[email protected]>
---
drivers/gpu/drm/arm/hdlcd_drv.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 340b1bb38bf9..f2bf9a61979d 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -297,11 +297,11 @@ static int hdlcd_probe(struct platform_device *pdev)
goto err_unload;
}
ret = pm_runtime_set_active(dev);
if (ret)
- goto err_pm_active;
+ goto err_unload;
pm_runtime_enable(dev);
ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
if (ret < 0) {
@@ -333,14 +333,13 @@ static int hdlcd_probe(struct platform_device *pdev)
return 0;
err_register:
drm_kms_helper_poll_fini(drm);
+ drm_atomic_helper_shutdown(drm);
err_vblank:
pm_runtime_disable(drm->dev);
-err_pm_active:
- drm_atomic_helper_shutdown(drm);
err_unload:
hdlcd_irq_uninstall(hdlcd);
of_reserved_mem_device_release(drm->dev);
err_free:
dev_set_drvdata(dev, NULL);
--
2.56.1