Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2700213pxj; Mon, 31 May 2021 08:33:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL13907HNRzWLhcfZe55Lf17a+Jtjj1xOAFEPJiAicUVC7V2OCTNBSIYTfiDzJx6jr3F3W X-Received: by 2002:a05:6402:3c1:: with SMTP id t1mr10949646edw.270.1622475234025; Mon, 31 May 2021 08:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475234; cv=none; d=google.com; s=arc-20160816; b=SQhZ802KJ4ByaA80S5LcSBX3kiNXdL56gqwmU5oT0lfkROdFZ+85sNaDuFE+phWoGl xSIHMmLr5mS/SKGtEVL+gyPqMJEmevTuiwwvw3Z0/D5pMLIPxZm61BOA/WMVWDkoWAkU YoVaEXRUEbF60O6HGsL4/udjUFtxXuAFwn+4hCazMSIktmILS4xANtkADBGE9cETsh/f 6lzYEHW6XcJi/g/gskfK6nP7zOAO/pRPRxbyzKSy2k6OaDeAyjRrrfm8TbfKEbj7l4jx yUxNnZ1ryukw6syqH/jX0SqFLt1uAYofz6Q6qOkbV5uQWIMKp1LHg7v++J15tspauRST FwYA== 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=ZA0wBKs4+cEX07gNhDX+PDksRYZN1XYvgxq8LzEmDAo=; b=VlHESx66gz8c04Oalx7WpdykxOnEX2OEEBkjK8tYR2KctE3jO/F8/kBp2Ju6VvU+0O qPe8vfrmnq2atct867DSmz7plmHiXgy9AO2uGV/Qq3hOtGyqGz45q4qBSy5ZM6Ysr8JC V8nLOxoyKOpYYaakW2JXN8Kxa3/s01oHMBHSebqb3h5psL3zjvx7fau1CBeKxKQcHfu5 kYIxYVqm9lu+RY2WN7jUjwI251mtcqCQBxQprd/Ze9wSiUrz+gBfuQHCMSD6foA6Oc3L jyMvjFcPk+H4QiZxsyiPGMEF8uBxVY3XQ4B4lJEkQUFRp4cmhPbI4OE614Iu12qDZHiI A/8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sHczhDGd; 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 h8si11615916edb.587.2021.05.31.08.33.31; Mon, 31 May 2021 08:33:54 -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=sHczhDGd; 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 S234644AbhEaPeF (ORCPT + 99 others); Mon, 31 May 2021 11:34:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:43708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233453AbhEaOSJ (ORCPT ); Mon, 31 May 2021 10:18:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DFAF9614A7; Mon, 31 May 2021 13:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468646; bh=I+y6PhPFeA3ZKAoAnJ6C0A1HMimOOjopEWWErD7NONs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sHczhDGdwvaTCj4sL8ckXIQG1n8jrYGP2vl3tz3d2Tn/eLXCofG3sLQ7wXinpEWP8 Z+fBvGg0o98I7J8tDjULxeCfpnNa/6z6LhFtR4slD6VP3jQEhCZvRDiANQaRxF33gp Oby2BV+NybYPiUWVovIoIbX+N01O6pJv0NIStwts= 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.4 071/177] drm/meson: fix shutdown crash when component not probed Date: Mon, 31 May 2021 15:13:48 +0200 Message-Id: <20210531130650.356128413@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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 @@ -423,11 +423,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)