From patchwork Wed Jun 8 12:56:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 69636 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2478190qgf; Wed, 8 Jun 2016 05:57:03 -0700 (PDT) X-Received: by 10.98.37.70 with SMTP id l67mr5689256pfl.56.1465390623587; Wed, 08 Jun 2016 05:57:03 -0700 (PDT) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id j72si1322140pfk.99.2016.06.08.05.57.03; Wed, 08 Jun 2016 05:57:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7DBFD6E9E5; Wed, 8 Jun 2016 12:57:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4668B6E9E5 for ; Wed, 8 Jun 2016 12:56:59 +0000 (UTC) Received: from e106497-lin.cambridge.arm.com (e106497-lin.cambridge.arm.com [10.2.131.153]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id u58CuseQ016457; Wed, 8 Jun 2016 13:56:54 +0100 From: Liviu Dudau To: Daniel Vetter , Robin Murphy Subject: [PATCH] drm: hdlcd: Unwind the DRM setup on error conditions in the right order. Date: Wed, 8 Jun 2016 13:56:53 +0100 Message-Id: <1465390613-15905-1-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.8.2 Cc: DRI Development X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In hdlcd_drm_bind()/hdlcd_drm_unbind() we unwind the DRM setup in the wrong order (drm_mode_config_cleanup() before connector and encoder had a chance to cleanup their memory or before drm_dev_unregister()). The correct order should match in both functions. Reported-by: Robin Murphy Signed-off-by: Liviu Dudau --- Robin, I believe this should fix your problems with HDLCD failing to allocate CMA memory and then crashing. Best regards, Liviu drivers/gpu/drm/arm/hdlcd_drv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c index 3422ca2..2c6eddb 100644 --- a/drivers/gpu/drm/arm/hdlcd_drv.c +++ b/drivers/gpu/drm/arm/hdlcd_drv.c @@ -382,7 +382,6 @@ static int hdlcd_drm_bind(struct device *dev) err_fbdev: drm_kms_helper_poll_fini(drm); - drm_mode_config_cleanup(drm); drm_vblank_cleanup(drm); err_vblank: pm_runtime_disable(drm->dev); @@ -390,6 +389,7 @@ err_pm_active: component_unbind_all(dev, drm); err_unregister: drm_dev_unregister(drm); + drm_mode_config_cleanup(drm); err_unload: drm_irq_uninstall(drm); of_reserved_mem_device_release(drm->dev); @@ -410,15 +410,15 @@ static void hdlcd_drm_unbind(struct device *dev) hdlcd->fbdev = NULL; } drm_kms_helper_poll_fini(drm); - component_unbind_all(dev, drm); drm_vblank_cleanup(drm); + component_unbind_all(dev, drm); pm_runtime_get_sync(drm->dev); drm_irq_uninstall(drm); pm_runtime_put_sync(drm->dev); pm_runtime_disable(drm->dev); - of_reserved_mem_device_release(drm->dev); - drm_mode_config_cleanup(drm); drm_dev_unregister(drm); + drm_mode_config_cleanup(drm); + of_reserved_mem_device_release(drm->dev); drm_dev_unref(drm); drm->dev_private = NULL; dev_set_drvdata(dev, NULL);