Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752716AbdHISKU (ORCPT ); Wed, 9 Aug 2017 14:10:20 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:36323 "EHLO mail-oi0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751995AbdHISKT (ORCPT ); Wed, 9 Aug 2017 14:10:19 -0400 MIME-Version: 1.0 In-Reply-To: <1502275263-7081-1-git-send-email-jeffy.chen@rock-chips.com> References: <1502275263-7081-1-git-send-email-jeffy.chen@rock-chips.com> From: Sean Paul Date: Wed, 9 Aug 2017 14:09:56 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drm/rockchip: Fix suspend crash when drm is not bound To: Jeffy Chen Cc: Linux Kernel Mailing List , Mark yao , Brian Norris , Doug Anderson , dri-devel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2812 Lines: 75 On Wed, Aug 9, 2017 at 6:41 AM, Jeffy Chen wrote: > Currently we are allocating drm_device in rockchip_drm_bind, so if the > suspend/resume code access it when drm is not bound, we would hit this > crash: > > [ 253.402836] Unable to handle kernel NULL pointer dereference at virtual address 00000028 > [ 253.402837] pgd = ffffffc06c9b0000 > [ 253.402841] [00000028] *pgd=0000000000000000, *pud=0000000000000000 > [ 253.402844] Internal error: Oops: 96000005 [#1] PREEMPT SMP > [ 253.402859] Modules linked in: btusb btrtl btbcm btintel bluetooth ath10k_pci ath10k_core ar10k_ath ar10k_mac80211 cfg80211 ip6table_filter asix usbnet mii > [ 253.402864] CPU: 4 PID: 1331 Comm: cat Not tainted 4.4.70 #15 > [ 253.402865] Hardware name: Google Scarlet (DT) > [ 253.402867] task: ffffffc076c0ce00 ti: ffffffc06c2c8000 task.ti: ffffffc06c2c8000 > [ 253.402871] PC is at rockchip_drm_sys_suspend+0x20/0x5c > > Add sanity checks to prevent that. > > Reported-by: Brian Norris > Signed-off-by: Jeffy Chen > Hi Jeffy, Thank you for the patch. In future, please also Cc dri-devel for more visibility (I've added them to this reply). I've applied the patch to drm-misc-fixes. Sean > --- > > drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > index c41f48a..ff3d0f5 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c > @@ -270,11 +270,15 @@ 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) > + 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); > @@ -288,8 +292,12 @@ 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) > + return 0; > > + priv = drm->dev_private; > drm_atomic_helper_resume(drm, priv->state); > rockchip_drm_fb_resume(drm); > drm_kms_helper_poll_enable(drm); > -- > 2.1.4 > >