Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2657008pxj; Mon, 31 May 2021 07:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzopsFpphajAOal/eXlT4a0z3bu9+yYS9hDpifdhx1LmtFVJbA3NSQqV8AbCypWOJ2qiEoF X-Received: by 2002:a17:906:5388:: with SMTP id g8mr23966332ejo.413.1622471611683; Mon, 31 May 2021 07:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622471611; cv=none; d=google.com; s=arc-20160816; b=jx6olkKV/GUasFUj5FHye/v8+lWEQTQDFOj0TWMC7d6VbgVt7UqByIITVrPgoOSYCA uOW+lgx1iM4mta8MNyyOr4VmspeSbHWWENjc3y7TlcAEWsuIxLVLQ1v3ag4FdKsPzpot 37+VgM3Ry9wzM5n9/Jw6Ql6kw3Yf5LQsPZWeWk+f8SKLMyFflkcNlPPnfKBmaype8FPy Au0LvtpUufa3PrnzG5OPFtEzRt4snGcxCTXqledNK0aO51ucr6igWVMMxs6YEdfMFyXR ro90p19IEFeC6T9gvRiYZET9YLnkuckpWO9Ra4MsO/ERsgWDIfInO05DKFIWz6svxXQS PX+Q== 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=D1i6xUmQ88CXoiAGzCpgsXzqsJmA95MOF7C8dfEm/nJhcmolexr/9ChrodueZtb+Ul tHRtd+vkQW8B/FjUtZNDsChbfxuXAzD3h8Bl+PERQvdwMfhHf3Hzh02GAjDRr+hBzO2P h0EBK1EsAJIJVsWjjELPBeEZoH7o21h8qAjd5jLPITp92tfZRwCG51bFlh0+Ea0jIrWa HaM/GIliqV1XTJDl7bFuCihWOz5aqf1tQcSiZkbY/b9gzymtnCIiNMWLAUAm2mTRbCDD LgshH6pzKAV3oAnnebqG/O/eredD885bMyjHtGMcHUXcv6pq41kvqzp7jDr3FzWnJniJ s/6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1lmgLH2i; 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 gb34si11496610ejc.697.2021.05.31.07.33.09; Mon, 31 May 2021 07:33:31 -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=1lmgLH2i; 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 S233362AbhEaOd5 (ORCPT + 99 others); Mon, 31 May 2021 10:33:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:59812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbhEaNzQ (ORCPT ); Mon, 31 May 2021 09:55:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5E5FC6143C; Mon, 31 May 2021 13:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468046; bh=evehsWDgrtvFFAaGhdrJiBjBwlzESMfUFXRcxpCubt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1lmgLH2iWbOapZbC5VC6NAbC7qHXiNlICYs+KYGlJqY6Rqf9R3OgUh6gjJxSP2hB0 x1UfiPHPICB2UQG3YX3y+GuAV3C05UwdqkRSux4ZIyWj+OvDycEmu0XnpP3Jl/XAAg 5KyQjrePChaUHqIxBW2bDUjSYElsoubu63TqC9hc= 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.10 096/252] drm/meson: fix shutdown crash when component not probed Date: Mon, 31 May 2021 15:12:41 +0200 Message-Id: <20210531130701.241539455@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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)