omapdrm_init() unwinds drm_vblank_init() and drm_dev_register()
failures through omap_modeset_fini() and then falls through to
err_gem_deinit, which calls drm_mode_config_cleanup() again.

omapdrm_cleanup() has the same problem during the normal teardown path:
it calls omap_modeset_fini() and then calls drm_mode_config_cleanup()
again afterwards.

omap_modeset_fini() should only undo omap_modeset_init(). The
drm_mode_config_init()/drm_mode_config_cleanup() pairing already lives
in the top-level init and cleanup paths, so keeping another
drm_mode_config_cleanup() inside omap_modeset_fini() causes repeated
cleanup of the same mode_config state.

Remove drm_mode_config_cleanup() from omap_modeset_fini() so each path
cleans mode_config exactly once.

Fixes: 2f95bc6d324a ("drm: omapdrm: Perform initialization/cleanup at 
probe/remove time")
Issue found using a prototype static analysis tool
and confirmed by code review.

Signed-off-by: Hongyan Xu <[email protected]>
Signed-off-by: Slavin Liu <[email protected]>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index bf0bad8c8cf1..838a1a236160 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -538,8 +538,6 @@ static int omap_modeset_init(struct drm_device *dev)
 static void omap_modeset_fini(struct drm_device *ddev)
 {
        omap_drm_irq_uninstall(ddev);
-
-       drm_mode_config_cleanup(ddev);
 }
 
 /*
-- 
2.50.1.windows.1

Reply via email to