Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2622205pxj; Mon, 31 May 2021 06:47:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+m8geVh6jAsOeaHB6qgsJJfulZMzIqWu3azRY25TgcxbtOZtX9ZRg5rhH08WZBqQd0+Sx X-Received: by 2002:a17:906:68da:: with SMTP id y26mr23282755ejr.514.1622468827943; Mon, 31 May 2021 06:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622468827; cv=none; d=google.com; s=arc-20160816; b=ugxhYy4OaURjKL7m3MuxP5CQG/1LbfmMmcPu0GM+c2YgOr0HKyTCSLM6ij6M0/GVp7 Oexkq6HtuypqNvORS3xEBxJ/dKyzBiVRGmnyKN7u4c8NChJqqTB0yiUAY3J8R6xbXUvQ mo7BK5rvS9B53IBVgJlpBubD4NN21Qq/f6i8ABWjFv8gS9jRCjBqKxj3JUm+2Brd4siJ 4CApYmeuL/XRijf4FPcMCHLZL5gGUTQPV0YNCdaU2Z32A8UBCCaTdsZwI/SDyjmQyqdf bf+AUFxaqIXt8fTWRiQvhwFTfSwlEnD+ShAO9aw7CY2rurHkQhm9WrKRCdooqlyanRU0 jUTg== 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=6PLSwxbVwZzCxMDxe6cm3L3/X8e2US6yCjn0+UUo0ew=; b=q1SlTEhQzVFvvnNgKOuitQk8qThmEk/qHmmmloGAvcbiQVbVU7Yy3swR2TnXoUiNLe oPWqrjRs7f7drauavewUYmZVo9r3RxS8oP3jGvWYzvcNK1JqnYyVltWi+JlouusT0FcN 4v0W9RE3onOHeJpOjcFActnEfh/xrOj1RD7cXZO5+yfCxe580jio4nx1U5OZOOVpPOkS wp9TpWzU4ebfhzkMzzrjnSxl1e9DFjFPccC6a9Tt9xuuNpYWK9VPT/NA8YI8cm0Gtyzo WmgcPYAYKLF6HNeQ12T9n3mlCrPPWYzlJpWeQTHgY8fXNUPKlgqw7PnjlyJQ0NXDs7BL KGtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lXcqA8dI; 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 hr12si12705999ejc.374.2021.05.31.06.46.44; Mon, 31 May 2021 06:47:07 -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=lXcqA8dI; 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 S232443AbhEaNrC (ORCPT + 99 others); Mon, 31 May 2021 09:47:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:40220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbhEaNc3 (ORCPT ); Mon, 31 May 2021 09:32:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B97DF6135D; Mon, 31 May 2021 13:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467443; bh=4pPF3576SbVzTBopJc0l9cXkMjzIN9CW7vY9obVO2Os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXcqA8dIt0SiTw4PGXqzYx54XPdmwXNNer9nP8dXd4N7I2orYefz9dFCbFlTqjWBw 9GuEF303zs84nzF8mNsvLPPUFzdk/3KD6vLce29zYtu/CAs2gSqBL4/AsZ2Zop7qgT EnbY0uLZPgfCQ56ijfkcC3v1i34a/ZNs8U4sMNKQ= 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.19 066/116] drm/meson: fix shutdown crash when component not probed Date: Mon, 31 May 2021 15:14:02 +0200 Message-Id: <20210531130642.395713882@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 @@ -387,11 +387,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)