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: 9164533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2732660467 for ; Wed, 8 Jun 2016 12:57:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18A8728179 for ; Wed, 8 Jun 2016 12:57:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D8172823D; Wed, 8 Jun 2016 12:57:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9445028179 for ; Wed, 8 Jun 2016 12:57:03 +0000 (UTC) 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Robin Murphy --- 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);