From patchwork Mon Oct 9 08:43:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 115184 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2304883qgn; Mon, 9 Oct 2017 01:44:08 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDCth+uxDiZdgSf+3RMuZC9A8OeBq+++ccj5FpEpL3HGvCVC6cLTuMWLDwqqodoyJ5uRHVe X-Received: by 10.98.8.74 with SMTP id c71mr2677276pfd.101.1507538648758; Mon, 09 Oct 2017 01:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507538648; cv=none; d=google.com; s=arc-20160816; b=kjpzVnqnXpsL9HndY5W7GWUNJNEakI2p4gW+Z8voqTuAXQ9wgZCkK5X5WtpVNOv9ie y2RqnPTsUi5YudtEaB6gkbeMBQVUVL7LmzzMPj70JGOSFsNQnnHxVOqlBGvjZwFxG+Md nW4st4tFkNn1nhrOzizDmfIPNI8gX7vRZQha2e9h2U0+j/xrluey/RExeDM3+O3KeEcc M8nxipi1DexxE5KN/yulsc4RA7Y8zl93urwdVGoCvV49sW1kot4dFg54PmEKOgkLQP0x 9OB+ySn7rP8vDsnjHw8ZDIh3D1mFpnTKttsOExmoxNfRe1lcGvTdvBuitY/1sVdgRYY3 K17w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ERyODhqIN5XTsYTAuFtFp/IzbG9DnaNKfgYSsnpKDD4=; b=ik472SYm5YlrE1aiHd8eScXy5NOASv7gKxLwAh+HghHhZyt/UYOm6xh0j+XC1JVraV AgsuaOsuBQCAuuMBM0tru9girQN5JD5DE70OKM1gX+5C3Lsky12+cTz+OGscC6Nmuqwa B5lOIqweVwbZ1mK1qzhTJxvjTrOCiqMOtG/zs27vySW11SseI7wyyHiBVioiehbstraj O8rRMJdRPLKXHC60qcj2qIWRQUXdUMJsJg6443BVDPjabBb6P0dkdUmxdJ6LotyHn9n9 4VENyM73JQibgPSSReMmWgZqw8gUKjVjM7B2wdWHsqsP5gg1jvxux5PFkGCooRltK1mn /5hg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si5975568plp.476.2017.10.09.01.44.08; Mon, 09 Oct 2017 01:44:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751834AbdJIIoH (ORCPT + 4 others); Mon, 9 Oct 2017 04:44:07 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:34157 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753840AbdJIIoE (ORCPT ); Mon, 9 Oct 2017 04:44:04 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171009084402euoutp0285a960049d8fe1feb468adf69f97fe44~r2miF91gO0112501125euoutp02b; Mon, 9 Oct 2017 08:44:02 +0000 (GMT) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171009084401eucas1p17aa6347fae5af66d9fe789bea8cf1135~r2mhUDofQ0583605836eucas1p15; Mon, 9 Oct 2017 08:44:01 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1.samsung.com (EUCPMTA) with SMTP id A1.03.12576.1D63BD95; Mon, 9 Oct 2017 09:44:01 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171009084401eucas1p17ff028dedb2d3ea47b6271beb16f854d~r2mgfC9270577805778eucas1p1B; Mon, 9 Oct 2017 08:44:01 +0000 (GMT) X-AuditID: cbfec7ef-f79ee6d000003120-64-59db36d167c4 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 78.01.20118.0D63BD95; Mon, 9 Oct 2017 09:44:00 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXJ00FTQS99ZZ60@eusync4.samsung.com>; Mon, 09 Oct 2017 09:44:00 +0100 (BST) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Andrzej Hajda , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Dan Carpenter Subject: [PATCH] drm/exynos: Fix potential NULL pointer dereference in suspend/resume paths Date: Mon, 09 Oct 2017 10:43:53 +0200 Message-id: <20171009084353.7190-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.14.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRmVeSWpSXmKPExsWy7djP87oXzW5HGmw8oG5xa905VouNM9az Wrz+N53F4srX92wWk+5PYLF4ce8ii8X58xvYLWac38dksfbIXSBr8ks2By6PTas62Tzudx9n 8vj49BaLR9+WVYwenzfJBbBGcdmkpOZklqU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EVSS4tz03OLjfSKE3OLS/PS9ZLzczcxAkNo27GfW3Ywdr0LPsQowMGoxMPbMO1W pBBrYllxZe4hRgkOZiUR3o9GtyOFeFMSK6tSi/Lji0pzUosPMUpzsCiJ8/buWR0pJJCeWJKa nZpakFoEk2Xi4JRqYDRdmSzldqKQzeWtmpxa77QdM1W454n/CQ47LT3//qufuTsklxWXVTTd 7zz66XjWArmnC1b4LLHRSzr6ctLF74+0793rztZgmxftFua39u+XRLeaBuVwSY83ZQ/XWU9u 5DF6ceHb8aIz7/LlHXZVTejWaXgRWuT0TeCS1Ylvgk6c6Rty/N2iYpRYijMSDbWYi4oTASFb rugdAgAA X-CMS-MailID: 20171009084401eucas1p17ff028dedb2d3ea47b6271beb16f854d X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-CMS-RootMailID: 20171009084401eucas1p17ff028dedb2d3ea47b6271beb16f854d X-RootMTR: 20171009084401eucas1p17ff028dedb2d3ea47b6271beb16f854d References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The patch 6e8edf8a7d8d: "drm/exynos: Fix suspend/resume support" introduced a new code in suspend/resume paths. However it unconditionally dereference drm_dev pointer, which might be NULL if suspend/resume happens before Exynos DRM driver components bind. This patch fixes this issue. Reported-by: Dan Carpenter Fixes: 6e8edf8a7d8d "drm/exynos: Fix suspend/resume support" Signed-off-by: Marek Szyprowski --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index e651a58c18cf..aa770bb0153c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -168,11 +168,13 @@ static struct drm_driver exynos_drm_driver = { static int exynos_drm_suspend(struct device *dev) { struct drm_device *drm_dev = dev_get_drvdata(dev); - struct exynos_drm_private *private = drm_dev->dev_private; + struct exynos_drm_private *private; if (pm_runtime_suspended(dev) || !drm_dev) return 0; + private = drm_dev->dev_private; + drm_kms_helper_poll_disable(drm_dev); exynos_drm_fbdev_suspend(drm_dev); private->suspend_state = drm_atomic_helper_suspend(drm_dev); @@ -188,11 +190,12 @@ static int exynos_drm_suspend(struct device *dev) static int exynos_drm_resume(struct device *dev) { struct drm_device *drm_dev = dev_get_drvdata(dev); - struct exynos_drm_private *private = drm_dev->dev_private; + struct exynos_drm_private *private; if (pm_runtime_suspended(dev) || !drm_dev) return 0; + private = drm_dev->dev_private; drm_atomic_helper_resume(drm_dev, private->suspend_state); exynos_drm_fbdev_resume(drm_dev); drm_kms_helper_poll_enable(drm_dev);