Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2731305pxj; Mon, 31 May 2021 09:18:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEbOVWZj5iNYaKE980M8Xjt4IsXdrkS1Dez4qv7BERH4qbSkRVXUo46GDqEHpL2fEGSrh0 X-Received: by 2002:a5e:8c11:: with SMTP id n17mr17355400ioj.53.1622477914989; Mon, 31 May 2021 09:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622477914; cv=none; d=google.com; s=arc-20160816; b=wzKPhU01NdF7YN+7hMBoXdBH5X0UZOqD91ZW0tsMuqHWzdmtyjmc9hW1BTn7ScEgfq 8cMefuWcazp996QI6S+hjV6oLVvpanr+jpOWoZBsKfoQOmN3zIp1Z1ky++RptFkxtD5N B85btOdQQU98jY68UXjvsHl+9hPY9Zyh/ndd9VZs1dY3IgSCEzPXOCNZ5dKqgUdAjRat BXgaeO/mdVGTyvX6sGf5ZpLn/pP9eejUjGXLEy6M48U/4ArQl/+d+F1w5bHloucpB4vE TEgXYSJOitkIlAvixLNKB66IpJ53/eYU0JwW6Voilpko6xdtgvsI/eKCXfmLzQY7v9c8 ETJA== 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=DiMvEXDeVP68NNES54bHveeV43u0qWthKLfj4x1k7OA=; b=PiAlZMhsdtECd9ZFSJSw9m4vcN8U3e0tbx2rUxM9LbzPiJvJoIjA8TOpfGuhav+AUM UJoJWRrWe3Mh76MHsXsfQGC8uAGP2szCRN9RYtHLL5Wt/KxjWJI3tfBu0eF2JOAjH4p9 AtGnw32OjXCcLQfvyEn5tIMLrN/rUjT8CtqJ/S6IiIQdtw83fAUdxKTQYLv//U6bxsIi b2kUcZmEMdaGYUpcMuz/kHvavaAZi41lEtbTE8n8Fiz5yBWvJ1frN/8vrTvMlG522vVG I0y8EBYyUhQIYumgZER9D4erp3Fdt2r0KVKTgwsXtBLRmE8efTUv/c33h5Y3c4na2U3O qdDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HqY3C63o; 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 k10si14089519iow.62.2021.05.31.09.18.21; Mon, 31 May 2021 09:18:34 -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=HqY3C63o; 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 S233419AbhEaQSo (ORCPT + 99 others); Mon, 31 May 2021 12:18:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:38034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233823AbhEaOlh (ORCPT ); Mon, 31 May 2021 10:41:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D88806190A; Mon, 31 May 2021 13:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469227; bh=evehsWDgrtvFFAaGhdrJiBjBwlzESMfUFXRcxpCubt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HqY3C63oLoVvodTJYEt8QNSdHCL5E6XPGEoDjkOCDOy03aGHRQcI0W39OS9gXi+xV gEJOCZOuUr/xLCI5+8xITFGL6T5zWA+aw28/OL/Abs/yT6HxF+FhdzxDCSZHoHbYne teaWbZszDenD8FZBAJNX2vVLBXavvyPsUrw9SRxU= 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 5.12 117/296] drm/meson: fix shutdown crash when component not probed Date: Mon, 31 May 2021 15:12:52 +0200 Message-Id: <20210531130707.853596116@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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 @@ -485,11 +485,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)