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: 9892425 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 8CFDA60363 for ; Wed, 9 Aug 2017 23:08:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E0CF289CE for ; Wed, 9 Aug 2017 23:08:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72B53289EC; Wed, 9 Aug 2017 23:08:52 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F071D289CE for ; Wed, 9 Aug 2017 23:08:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=M6pFNx7FwhdGUB8UO98YpYUhupO1QfhZD204r0SlOc4=; b=blP UGcqnm/6q+uPnVorkneYtRVp20PyIzxCEx9IwNpwu97knC6sHJynUxcVaor+0kY6ix4RyRFVXwGnD XbwphKK5xy+wwzwzq/pvjfYXoelfGxIK0n0EpH0KDKpxl0YL6OebYw44LSB2zmliZ3kSuZ1U57VYW QyKrL7sxPiiCyLXAVDm5oEqWLHbqkyMOlg+LjbJLLbggVav4Fq1Vwz2KHI4VUsisu+TEImQOSctjN QyBecHvhS+Hq0K+Cbc6rnnEerBz91njqneHfwxZCyBbCBjTquOlnRj7BlCS4vBwKQrouJ0xg1ZZHM xVh0/q0xgW/bElcoq3QCvi914oEWpJQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dfa5l-0004Z0-Bs; Wed, 09 Aug 2017 23:08:45 +0000 Received: from mail-pf0-f171.google.com ([209.85.192.171]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dfa5h-0004Wr-LX for linux-arm-kernel@lists.infradead.org; Wed, 09 Aug 2017 23:08:43 +0000 Received: by mail-pf0-f171.google.com with SMTP id c28so33562483pfe.3 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=H1BvOsKM659588R7VgrdPIZY7vuitKOPpXaAurBmNe/bLH0ejkx93BLGnnuw4qpbGj YybhOEkIi8Ldjr8EE9V14/UBu2lzKOVUzYOxHErlGp/8nnOd5IQC4a8QC2ZCrGcP5TDg eBDnjMNzdHTxrHxajZD0yuiS4UgoZjAM9FNETI0OmrGovysvIcfUJeflgrjX2BqmCCz7 7J9xjGublnVulG6LmApniqcUgz17456QLOSlQlPBMLzWdEFfGot4dchS4QLsM+bzfwPW 4ywoCZknwzVqIFpEq+qeqNRkX69QNGJXHCVJHuj/hsdifzmE2kiKL1V867HkiWvcfa/N PQfg== X-Gm-Message-State: AHYfb5iWrzoHUdLN1YWwFaI06jwoNX3e/T2h79PuJl8/TlRJOOruPnbx QunXRBCkZyHf34s/ 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170809_160841_732429_51437506 X-CRM114-Status: GOOD ( 11.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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);