From patchwork Thu Nov 13 16:37:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 5299221 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 298559F2F1 for ; Thu, 13 Nov 2014 16:38:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5138820211 for ; Thu, 13 Nov 2014 16:38:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6E6F1201F4 for ; Thu, 13 Nov 2014 16:38:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 94EA16E4BA; Thu, 13 Nov 2014 08:38:20 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.w1.samsung.com (mailout4.w1.samsung.com [210.118.77.14]) by gabe.freedesktop.org (Postfix) with ESMTP id 300256E4BA for ; Thu, 13 Nov 2014 08:38:19 -0800 (PST) Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEZ00M5JL0EF590@mailout4.w1.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 13 Nov 2014 16:41:02 +0000 (GMT) X-AuditID: cbfec7f4-b7f6c6d00000120b-15-5464de790908 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 23.58.04619.97ED4645; Thu, 13 Nov 2014 16:38:17 +0000 (GMT) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NEZ00FSHKV93H60@eusync2.samsung.com>; Thu, 13 Nov 2014 16:38:16 +0000 (GMT) From: Andrzej Hajda To: Inki Dae Subject: [PATCH 7/7] drm/exynos/crtc: add NULL checks before accessing crtc Date: Thu, 13 Nov 2014 17:37:48 +0100 Message-id: <1415896668-27226-8-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1415896668-27226-1-git-send-email-a.hajda@samsung.com> References: <1415896668-27226-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLJMWRmVeSWpSXmKPExsVy+t/xK7qV91JCDNaHWNxad47V4srX92wW k+5PYLF4ce8ii8XaI3fZHVg97ncfZ/Lo27KKMYApissmJTUnsyy1SN8ugStj04VtTAU3JCuW 951iaWA8LNbFyMkhIWAisamrix3CFpO4cG89WxcjF4eQwFJGiWd7L7CCJIQE+pgkXk9xALHZ BDQl/m6+yQZiiwgoS6za184O0sAssJhR4kHDLbAGYQFviW3NzcwgNouAqsSlXe9ZQGxeAWeJ xgW/GSG2yUmcPDYZrJ5TwEWid9FiZohlzhLvp61nncDIu4CRYRWjaGppckFxUnquoV5xYm5x aV66XnJ+7iZGSJB82cG4+JjVIUYBDkYlHt4P3CkhQqyJZcWVuYcYJTiYlUR4vQ8DhXhTEiur Uovy44tKc1KLDzEycXBKNTAuu+nwluOipTTX+b09F8W31TX2s/VzVK/aYrH8ynQD2WNz18t3 9MtPeW/R8+KMH/ua9vTZPxsfSPYEHAvOW3DB8Gvlm/l6///YX5RgTgy8FR8oo6Ty94joU3bv ry/WmXQ5zv4l0logUld+fWKnedGimw/usZw6s+P223cz1u8Uu5WlcD5yldNuJZbijERDLeai 4kQAvY5rP/ABAAA= Cc: Andrzej Hajda , dri-devel@lists.freedesktop.org, Marek Szyprowski 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-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP exynos_drm_crtc_disable_vblank can be called when drm initialization fails. In such case some structures are not initialized, so the function should check it. The patch adds necessary checks. It fixes following Oops: [ 1.521834] Unable to handle kernel NULL pointer dereference at virtual address 00000348 ... [ 1.801740] [] (exynos_drm_crtc_disable_vblank) from [] (vblank_disable_and_save+0x74/0x1e8) [ 1.811893] [] (vblank_disable_and_save) from [] (drm_vblank_cleanup+0x50/0x80) [ 1.820918] [] (drm_vblank_cleanup) from [] (exynos_drm_load+0xe8/0x118) [ 1.829338] [] (exynos_drm_load) from [] (drm_dev_register+0xa0/0x100) [ 1.837585] [] (drm_dev_register) from [] (drm_platform_init+0x40/0xd0) [ 1.845919] [] (drm_platform_init) from [] (try_to_bring_up_master.part.2+0xc8/0x104) [ 1.855467] [] (try_to_bring_up_master.part.2) from [] (component_master_add_with_match+0xa4/0x124) [ 1.866227] [] (component_master_add_with_match) from [] (exynos_drm_platform_probe+0x10c/0x158) [ 1.876731] [] (exynos_drm_platform_probe) from [] (platform_drv_probe+0x48/0xa4) [ 1.885932] [] (platform_drv_probe) from [] (driver_probe_device+0x10c/0x22c) [ 1.894784] [] (driver_probe_device) from [] (__driver_attach+0x8c/0x90) [ 1.903203] [] (__driver_attach) from [] (bus_for_each_dev+0x54/0x88) [ 1.911363] [] (bus_for_each_dev) from [] (bus_add_driver+0xd4/0x1d0) [ 1.919522] [] (bus_add_driver) from [] (driver_register+0x78/0xf4) [ 1.927507] [] (driver_register) from [] (exynos_drm_init+0x64/0x8c) [ 1.935580] [] (exynos_drm_init) from [] (do_one_initcall+0x80/0x1b8) [ 1.943743] [] (do_one_initcall) from [] (kernel_init_freeable+0xfc/0x1c8) [ 1.952334] [] (kernel_init_freeable) from [] (kernel_init+0x8/0xec) [ 1.960406] [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 45026e6..e05fe12 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -406,9 +406,14 @@ int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe) void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe) { struct exynos_drm_private *private = dev->dev_private; - struct exynos_drm_crtc *exynos_crtc = - to_exynos_crtc(private->crtc[pipe]); - struct exynos_drm_manager *manager = exynos_crtc->manager; + struct exynos_drm_crtc *exynos_crtc; + struct exynos_drm_manager *manager; + + if (!private->crtc[pipe]) + return; + + exynos_crtc = to_exynos_crtc(private->crtc[pipe]); + manager = exynos_crtc->manager; if (exynos_crtc->dpms != DRM_MODE_DPMS_ON) return;