From patchwork Wed Aug 9 23:07:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 9892421 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 97EDB60363 for ; Wed, 9 Aug 2017 23:08:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80358289CE for ; Wed, 9 Aug 2017 23:08:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74B0A28A09; Wed, 9 Aug 2017 23:08:24 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08F6C289CE for ; Wed, 9 Aug 2017 23:08:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6AF416E4D1; Wed, 9 Aug 2017 23:08:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-f181.google.com (mail-pf0-f181.google.com [209.85.192.181]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A15C6E4D1 for ; Wed, 9 Aug 2017 23:08:20 +0000 (UTC) Received: by mail-pf0-f181.google.com with SMTP id t86so33544124pfe.2 for ; Wed, 09 Aug 2017 16:08:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gbIrvc+5r3PWPHs1IxYUIg8mNYqlfCsu5gJFizUbb2g=; b=fZe3JDPZEeHXEQvVtRgsBhhlBkd9BogwG2TkuGFdwiELxDirgha+v759asxMBrngOi 80zB9R4c0bA2OEdASDxRJLoiS+qkfcXwU1X0zhD0ANVR0xwc4v7LrEeTH0SMwmlYnO/A sdvfbLymRC//QTEeWbNvAUXhHfIxk6mjXo5Ov0FNOzkjr/bcD1l2iuERXJVSVT2ESkgn s/yOmpc0laY/JnVYM1SAGba70LWI+9Ol7blfJlBADjEfNPAvm/Nv4mI9xpxx+MniX3Ly KHwkn15xH1e40CxALcOlYYAP/gn3wxV1l43i/gqY13YKYc9tVsRNls3Ju2auVdYDhSX2 5u/g== X-Gm-Message-State: AHYfb5hCvP1meZltRGN+iIbeH+eKVeqdHpwrZMVqhvIyYWsTqX62xFk9 33lZJU+dBOs4l8f1sWFPmQ== X-Received: by 10.99.170.3 with SMTP id e3mr9060698pgf.411.1502320099641; Wed, 09 Aug 2017 16:08:19 -0700 (PDT) Received: from mka.mtv.corp.google.com ([172.22.112.49]) by smtp.gmail.com with ESMTPSA id b77sm9663802pfe.54.2017.08.09.16.08.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Aug 2017 16:08:19 -0700 (PDT) From: Matthias Kaehlcke To: Mark Yao , David Airlie , Heiko Stuebner Subject: [PATCH] drm/rockchip: Skip suspend/resume if no display is attached Date: Wed, 9 Aug 2017 16:07:24 -0700 Message-Id: <20170809230724.113819-1-mka@chromium.org> X-Mailer: git-send-email 2.14.0.434.g98096fd7a8-goog Cc: Brian Norris , Doug Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Kaehlcke , linux-arm-kernel@lists.infradead.org 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 rockchip_drm_sys_suspend/resume() obains a struct drm_device pointer from drvdata, the pointer is then dereferenced to obtain private data. drvdata is set when a display is bound, on systems without a (successfully probed) display drvdata is NULL and the PM functions try to dereference a NULL pointer. The suspend/resume code relies on a valid drm_device object, skip it if the pointer is NULL. Signed-off-by: Matthias Kaehlcke --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index c6b1b7f3a2a3..6228145d9496 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -275,11 +275,16 @@ static void rockchip_drm_fb_resume(struct drm_device *drm) static int rockchip_drm_sys_suspend(struct device *dev) { struct drm_device *drm = dev_get_drvdata(dev); - struct rockchip_drm_private *priv = drm->dev_private; + struct rockchip_drm_private *priv; + + if (!drm) + /* no display attached */ + return 0; drm_kms_helper_poll_disable(drm); rockchip_drm_fb_suspend(drm); + priv = drm->dev_private; priv->state = drm_atomic_helper_suspend(drm); if (IS_ERR(priv->state)) { rockchip_drm_fb_resume(drm); @@ -293,8 +298,13 @@ static int rockchip_drm_sys_suspend(struct device *dev) static int rockchip_drm_sys_resume(struct device *dev) { struct drm_device *drm = dev_get_drvdata(dev); - struct rockchip_drm_private *priv = drm->dev_private; + struct rockchip_drm_private *priv; + + if (!drm) + /* no display attached */ + return 0; + priv = drm->dev_private; drm_atomic_helper_resume(drm, priv->state); rockchip_drm_fb_resume(drm); drm_kms_helper_poll_enable(drm);