From patchwork Fri Jul 29 09:06:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alisa Khabibrakhmanova X-Patchwork-Id: 12932213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C336C00144 for ; Fri, 29 Jul 2022 09:07:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 243F510E1F5; Fri, 29 Jul 2022 09:07:28 +0000 (UTC) Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4347E12B2E8 for ; Fri, 29 Jul 2022 09:06:50 +0000 (UTC) Received: from alisa-ThinkPad-T440s.. (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPS id 575CF40737DF; Fri, 29 Jul 2022 09:06:44 +0000 (UTC) From: Alisa Khabibrakhmanova To: David Airlie , Daniel Vetter , Thomas Zimmermann , Sam Ravnborg Subject: [PATCH] drm/via: Add new condition to via_dma_cleanup() Date: Fri, 29 Jul 2022 12:06:43 +0300 Message-Id: <20220729090643.240778-1-khabibrakhmanova@ispras.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ldv-project@linuxtesting.org, Alisa Khabibrakhmanova , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Pointer dev_priv->mmio, which was checked for NULL at via_do_init_map(), is passed to via_do_cleanup_map() and is dereferenced there without check. The patch adds the condition in via_dma_cleanup() which prevents potential NULL pointer dereference. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 22f579c621e2 ("drm: Add via unichrome support") Signed-off-by: Alisa Khabibrakhmanova --- drivers/gpu/drm/via/via_dri1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/via/via_dri1.c b/drivers/gpu/drm/via/via_dri1.c index d695d9291ece..691e3ceb0062 100644 --- a/drivers/gpu/drm/via/via_dri1.c +++ b/drivers/gpu/drm/via/via_dri1.c @@ -2961,7 +2961,7 @@ int via_dma_cleanup(struct drm_device *dev) drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; - if (dev_priv->ring.virtual_start) { + if (dev_priv->ring.virtual_start && dev_priv->mmio) { via_cmdbuf_reset(dev_priv); drm_legacy_ioremapfree(&dev_priv->ring.map, dev);