Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2637749pxj; Mon, 31 May 2021 07:07:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy286X1FidHUEXB0uKq6H+rOHAUy2nK48jikHsApS9WEixvOOvkPd3YmbcTwKVCWnukOEFs X-Received: by 2002:a05:6638:148c:: with SMTP id j12mr4071497jak.74.1622470057950; Mon, 31 May 2021 07:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622470057; cv=none; d=google.com; s=arc-20160816; b=OaaWdtKBDGTC1QEYIYVAmGKs2RVgDc9RVggL5QjIabUDB8mim96gKlKXMkXEgwpJaf z2apiWURcuYOXzav2nuOnlXbowt11huj3QcXmjQMYMI+8t4DDIaQiG5qJCS2Shd1ezvN gxGadmZUNeWGSysHEqf/MnwFMYCBQPgH7lQhDCnByIe+XGGxwmdQYPWPnz7p1gzFvxo3 G8oFCoaXjvylPNWTNsugf4jp9Ae3ja7ZpX3uJOmuOvcGT8QhdLVftK+jq/1804uLg9mR JZ6VnJdUoTDZu66c/7kj7UDhpx//GSc2p+Rx0Y/56wUQQNCFynZ/NEmqutQNnCYQw4Be wGGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NpqHsZ0S9xcErl8qy8GO4tA01+yNfQFkkr17v+Hv1pA=; b=WMfP44NE81gQTcF0z1O5ejQuGiyhnX9W7Mh1GD25LA8aUmALx+2m6WDztass/Zm80Z /vBPH+N1xJctebI9rIGjDL91t0FvtojirR8G+UyQ+FCaWy8GGj2LE7TCUtzBh+zoXuOJ dd95P5E9Uw2dwleIrdgCLC1TjtaCkRh5hW5dXDnvf8U8EfVRFt+rI5yiBqQxboeRIivk aDx6oogNyUED4ZUJPFK3kMYjYZkOAfrpIFC2uekha9bkUSwSpSyqYXjLXiaRtswN22YH cTDc0GPuiR8wrNjE6jyUrntbX51gX2X/pdilYYgRZC4SyO1YBQXywnRLEtrhqJ499o8X k5uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vZ15utYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n20si14335433jat.115.2021.05.31.07.07.24; Mon, 31 May 2021 07:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vZ15utYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232556AbhEaOI3 (ORCPT + 99 others); Mon, 31 May 2021 10:08:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbhEaNnA (ORCPT ); Mon, 31 May 2021 09:43:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CA4CE61483; Mon, 31 May 2021 13:28:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467721; bh=/AR6sw5pzaS0ed642hqWFyYDQ9w5U8GATj9I4hP0v1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZ15utYCJcgcv4W9y3AeRK95nYN1q06+5d7j0wRgqPANSu9fHI6El57whIUQ0MJ2v EfHj/y2sSqAcJMxywcPoIJumZFYqtLacUrgATxeJO4EOsSAengWrSM2tvfFcvVivgT wdygLm6pMB5hWQ30iaQYk1Xsu6tEMteRXfMOqja0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Agner , Neil Armstrong , Martin Blumenstingl Subject: [PATCH 4.14 38/79] drm/meson: fix shutdown crash when component not probed Date: Mon, 31 May 2021 15:14:23 +0200 Message-Id: <20210531130637.235108218@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130636.002722319@linuxfoundation.org> References: <20210531130636.002722319@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Neil Armstrong commit 7cfc4ea78fc103ea51ecbacd9236abb5b1c490d2 upstream. When main component is not probed, by example when the dw-hdmi module is not loaded yet or in probe defer, the following crash appears on shutdown: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000038 ... pc : meson_drv_shutdown+0x24/0x50 lr : platform_drv_shutdown+0x20/0x30 ... Call trace: meson_drv_shutdown+0x24/0x50 platform_drv_shutdown+0x20/0x30 device_shutdown+0x158/0x360 kernel_restart_prepare+0x38/0x48 kernel_restart+0x18/0x68 __do_sys_reboot+0x224/0x250 __arm64_sys_reboot+0x24/0x30 ... Simply check if the priv struct has been allocated before using it. Fixes: fa0c16caf3d7 ("drm: meson_drv add shutdown function") Reported-by: Stefan Agner Signed-off-by: Neil Armstrong Tested-by: Martin Blumenstingl Reviewed-by: Martin Blumenstingl Link: https://patchwork.freedesktop.org/patch/msgid/20210430082744.3638743-1-narmstrong@baylibre.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/meson/meson_drv.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -364,11 +364,12 @@ static int meson_probe_remote(struct pla static void meson_drv_shutdown(struct platform_device *pdev) { struct meson_drm *priv = dev_get_drvdata(&pdev->dev); - struct drm_device *drm = priv->drm; - DRM_DEBUG_DRIVER("\n"); - drm_kms_helper_poll_fini(drm); - drm_atomic_helper_shutdown(drm); + if (!priv) + return; + + drm_kms_helper_poll_fini(priv->drm); + drm_atomic_helper_shutdown(priv->drm); } static int meson_drv_probe(struct platform_device *pdev)