From patchwork Mon Aug 14 21:53:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 9900403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF499602D9 for ; Mon, 14 Aug 2017 23:47:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D31C28782 for ; Mon, 14 Aug 2017 23:47:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81D282878F; Mon, 14 Aug 2017 23:47:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A70D828789 for ; Mon, 14 Aug 2017 23:47:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E8C76E27D; Mon, 14 Aug 2017 23:46:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from rere.qmqm.pl (78-11-180-123.static.ip.netia.com.pl [78.11.180.123]) by gabe.freedesktop.org (Postfix) with ESMTPS id 723C989FAC for ; Mon, 14 Aug 2017 21:53:48 +0000 (UTC) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 3xWTrp1qzTz39; Mon, 14 Aug 2017 23:53:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1502747626; bh=hR8kTpy0r7PzabQATKORPzaawWkNlQvba1+ddzT5vCk=; h=Date:From:Subject:To:Cc:From; b=omYo+jq8Uckra5SkFI7ZMkKKqhMnIhYxfCnyy+zQo/1ya0qe9e3ZhjJlmH7S01uFH Vr+vLWUc45N5jqm7QtSk35KH8wVSQdBVyElZyxVhbAJHiYtpELYrrpuCCjz1m+Fsa4 acWRb+4Eovvu7g72xZlaVfVVmG037hb0WQFvAGTqjrnjZMem+C3u2IHdjx13qJoCnF +xLsW1vV1tjbtSGTImGl4cLM2k+w4cKUrNKidwLbKZ8xFeji08H3R9MQqhbi55jj9j krv4UseIAxPKmbxakXY4XKiGYj0IYMBqHK3WsKg5WlJnfElupfZgf4MBMf24OB5T/J +enpC/bd3+gbw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at rere Date: Mon, 14 Aug 2017 23:53:45 +0200 Message-Id: <7ca7b47df4aa1c164b7313172564923a2639dcc1.1502747460.git.mirq-linux@rere.qmqm.pl> From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH] drm: tegra: fix NULL deref in debugfs/iova MIME-Version: 1.0 To: Thierry Reding , David Airlie , Jonathan Hunter X-Mailman-Approved-At: Mon, 14 Aug 2017 23:46:28 +0000 Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When IOMMU is off, ->mm_lock is not initialized and ->mm is NULL. Signed-off-by: Michał Mirosław --- drivers/gpu/drm/tegra/drm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 8b7842548b9f..f859c06b8ab0 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1033,9 +1033,11 @@ static int tegra_debugfs_iova(struct seq_file *s, void *data) struct tegra_drm *tegra = drm->dev_private; struct drm_printer p = drm_seq_file_printer(s); - mutex_lock(&tegra->mm_lock); - drm_mm_print(&tegra->mm, &p); - mutex_unlock(&tegra->mm_lock); + if (tegra->domain) { + mutex_lock(&tegra->mm_lock); + drm_mm_print(&tegra->mm, &p); + mutex_unlock(&tegra->mm_lock); + } return 0; }