sti_cleanup() is shared between sti_unbind() and the sti_bind()
error paths, and calls drm_atomic_helper_shutdown().
However, on the error paths the initial state may not have been
created yet: when component_bind_all() or drm_dev_register() fails,
drm_mode_config_reset() hasn't run and the CRTC state is still NULL.
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() out of sti_cleanup() and into
sti_unbind(), so that it's only ever called on a fully initialized
device. It still runs after drm_dev_unregister() and before
drm_mode_config_cleanup(), as it did before.
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: a2b50babc7439 ("drm/sti: Use drm_atomic_helper_shutdown")
Reported-by: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Maxime Ripard <[email protected]>
---
drivers/gpu/drm/sti/sti_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 0ca6c6b41f18..794badf199c9 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -171,11 +171,10 @@ static int sti_init(struct drm_device *ddev)
static void sti_cleanup(struct drm_device *ddev)
{
struct sti_private *private = ddev->dev_private;
drm_kms_helper_poll_fini(ddev);
- drm_atomic_helper_shutdown(ddev);
drm_mode_config_cleanup(ddev);
component_unbind_all(ddev->dev, ddev);
dev_set_drvdata(ddev->dev, NULL);
kfree(private);
ddev->dev_private = NULL;
@@ -222,10 +221,11 @@ static int sti_bind(struct device *dev)
static void sti_unbind(struct device *dev)
{
struct drm_device *ddev = dev_get_drvdata(dev);
drm_dev_unregister(ddev);
+ drm_atomic_helper_shutdown(ddev);
sti_cleanup(ddev);
drm_dev_put(ddev);
}
static const struct component_master_ops sti_ops = {
--
2.56.1