Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13931221pxu; Mon, 4 Jan 2021 08:15:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIAgaU13e9QVi+VbqKa9m+7r2i1tGn0clHjNYO1OjnUQ7K5OAcjv/m0haJFhSzvb25L4qM X-Received: by 2002:aa7:d511:: with SMTP id y17mr71717335edq.249.1609776927420; Mon, 04 Jan 2021 08:15:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609776927; cv=none; d=google.com; s=arc-20160816; b=Sl8V30Z4isP3ULvfRu2j0y8UCnMPedsJo82gQ4Zk3CSFcpGTkOZmwFmOYLDQnDCDYl Ef1gHfk0a87B1DGE3rlYb1VouQzZvdEF8rx6SGgpksMaGLLpYiiy/hxmCS9x1bepVNDV BtG5Y7vMJlRzjfgbgXuAaVptAg9ZEawexNrJQLHOFi5dLOKacj5Hyeu8aUcmy6Vgw7Gw Ni37Ovp/9+Kiezl2wHy/Tm8ZrGG8ckahU1eeVyjqvCxsn78pSol/M6Wfpx6arpIjt6Rw ZtQDfbnudsGSMM//hWsoT7DIlSnp4VXCxq5vIA8lKXLhOi3nI3rxr6j7+GiN1/XJWKto hpWg== 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=DlroXvV56seJrE5YAI1an1nJywIGOinZarYW5Xxc7Pk=; b=MDLGDqwQfszrh8rhn1Rs3aTQoAW2ACw9ygl1HBecOUiCi/IglO7WPHpr8FAiSKDGr5 57x6ee6WmnThvDZoACroRGv3dA+qRZPcfRR1BI6015sz2Uyu7UbFlQlOlHApxU80eg99 hS2DfsD9Bn38owSVdvT0qh1xaYVU/WsES+I/zif9j3EPbF+x72kBsgsL+12cZbYQPX46 hFtSihqlUIZW+1qENY/cxCHMnHXd+j5aaZHscv4uzOzKg0K5cl7hTTVbuaQWDiw9q8pe z7PX0GZSw+GlogBWwGbSOTKCsVF8LaMiR0V+JwAbddOs3aW6+XSqJ/FRmGECqseLxQpl frsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=de3sv+nt; 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 g1si30842908ejf.377.2021.01.04.08.15.03; Mon, 04 Jan 2021 08:15:27 -0800 (PST) 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=de3sv+nt; 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 S1729532AbhADQLa (ORCPT + 99 others); Mon, 4 Jan 2021 11:11:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:36516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728150AbhADQAM (ORCPT ); Mon, 4 Jan 2021 11:00:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B2C422515; Mon, 4 Jan 2021 15:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609775988; bh=aBD8XTv1hrjbZueewUSzSmIkCGjr/4aUcV3aQVFCMyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=de3sv+ntnHaggEJkZyKPm4LWxKT2UgfGdaEUjc1tWl1DmRWMhuH8Zop07fZGzpg7P GcVpxVFrxK3Jn1wL/2GrrAVQLsBhQeOnovIIx2lgqjJ5WpKc+tJd8m1dcHrZBmOIdy HB8RSKnYX6rIuRElLKqoSkDzSo1KnvofM0umqjfM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Auger , Alex Williamson , Sasha Levin Subject: [PATCH 5.4 09/47] vfio/pci: Move dummy_resources_list init in vfio_pci_probe() Date: Mon, 4 Jan 2021 16:57:08 +0100 Message-Id: <20210104155706.203265366@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210104155705.740576914@linuxfoundation.org> References: <20210104155705.740576914@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: Eric Auger [ Upstream commit 16b8fe4caf499ae8e12d2ab1b1324497e36a7b83 ] In case an error occurs in vfio_pci_enable() before the call to vfio_pci_probe_mmaps(), vfio_pci_disable() will try to iterate on an uninitialized list and cause a kernel panic. Lets move to the initialization to vfio_pci_probe() to fix the issue. Signed-off-by: Eric Auger Fixes: 05f0c03fbac1 ("vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive") CC: Stable # v4.7+ Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin --- drivers/vfio/pci/vfio_pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 632653cd70e3b..2372e161cd5e8 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -114,8 +114,6 @@ static void vfio_pci_probe_mmaps(struct vfio_pci_device *vdev) int bar; struct vfio_pci_dummy_resource *dummy_res; - INIT_LIST_HEAD(&vdev->dummy_resources_list); - for (bar = PCI_STD_RESOURCES; bar <= PCI_STD_RESOURCE_END; bar++) { res = vdev->pdev->resource + bar; @@ -1606,6 +1604,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) mutex_init(&vdev->igate); spin_lock_init(&vdev->irqlock); mutex_init(&vdev->ioeventfds_lock); + INIT_LIST_HEAD(&vdev->dummy_resources_list); INIT_LIST_HEAD(&vdev->ioeventfds_list); mutex_init(&vdev->vma_lock); INIT_LIST_HEAD(&vdev->vma_list); -- 2.27.0