If there is no framebuffer mode that can be restored, all outputs should
be disabled in order to avoid information leaks.

Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
 drivers/gpu/drm/imx/imx-drm-core.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 82656654fb21..c63378661e11 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -63,7 +63,19 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
 {
        struct imx_drm_device *imxdrm = drm->dev_private;

-       drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
+       if (imxdrm->fbhelper) {
+               drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
+       } else {
+               struct drm_connector *connector;
+
+               /* no kernel mode to go back to, disable all outputs */
+               drm_modeset_lock_all(drm);
+               drm_for_each_connector(connector, drm)
+                       connector->encoder = NULL;
+               drm_modeset_unlock_all(drm);
+
+               drm_helper_disable_unused_functions(drm);
+       }
 }

 static int imx_drm_driver_unload(struct drm_device *drm)
-- 
2.8.1

Reply via email to