From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84277C11F67 for ; Wed, 14 Jul 2021 16:49:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 46846613D2 for ; Wed, 14 Jul 2021 16:49:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46846613D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C356F6E3F5; Wed, 14 Jul 2021 16:49:21 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 12E506E3F5 for ; Wed, 14 Jul 2021 16:49:20 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id B302D613C3; Wed, 14 Jul 2021 16:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626281359; bh=6SKB3Qqjs+EC5rQxtbZljNFZlyLM4HZOJZxqpbfl9sM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ko/UfbhD+PKfNZ3iK4ym6LzrxkwTJIAnlAs+qXdzedMZaGQBceXrGL4yO3Mhi8Yui vMOTVVJx+4Ujke2mPgfBk3Ht3ixeEAIiueMcl+Mt3nZdEGKe/obO9fAbsIwGZd2S1E wlHDb7pZo4ORM9aKt7vjHyClabpj5MHNp1aihZ0eiiUfnZphY1Cf8Si2OtplBMmvoA FklATVbj/QyXl8hG1qWEX00mxNkUQ0OdAccH8p4pfKml6iQ2yveG5hqAcabY/0PnHT ShhjQGUDah6fa1UE1UZsYnAqBBPNlHHBWN0dRxflqSplK04t3uzsQ1hpgqx1ZY+qSN 8z4l8b9ME85bA== Date: Wed, 14 Jul 2021 12:49:18 -0400 From: Sasha Levin To: Pavel Machek Subject: Re: [PATCH AUTOSEL 4.4 08/31] drm/virtio: Fixes a potential NULL pointer dereference on probe failure Message-ID: References: <20210706112931.2066397-1-sashal@kernel.org> <20210706112931.2066397-8-sashal@kernel.org> <20210712215937.GA9488@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210712215937.GA9488@amd> 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, Xie Yongji , stable@vger.kernel.org, Gerd Hoffmann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Jul 12, 2021 at 11:59:37PM +0200, Pavel Machek wrote: >Hi! > >> From: Xie Yongji >> >> [ Upstream commit 17f46f488a5d82c5568e6e786cd760bba1c2ee09 ] >> >> The dev->dev_private might not be allocated if virtio_gpu_pci_quirk() >> or virtio_gpu_init() failed. In this case, we should avoid the cleanup >> in virtio_gpu_release(). > >The check is in wrong place at least in 4.4: > >> +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c >> @@ -257,6 +257,9 @@ int virtio_gpu_driver_unload(struct drm_device *dev) >> flush_work(&vgdev->config_changed_work); >> vgdev->vdev->config->del_vqs(vgdev->vdev); >> >> + if (!vgdev) >> + return; >> + > >Pointer is dereferenced before being tested. Heh, yes, thanks for catching that. I'll drop it for now and rework it next week. -- Thanks, Sasha