Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp348363pxu; Thu, 7 Jan 2021 06:39:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwqwljs6H4IYKZNxXHtzRQ1ZG3uNStjOiHnJ6mGR+qtXK3mipsoqy3nXSbWb/xGAf1C4ok X-Received: by 2002:a05:6402:41:: with SMTP id f1mr1856267edu.286.1610030386734; Thu, 07 Jan 2021 06:39:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610030386; cv=none; d=google.com; s=arc-20160816; b=cjtzyimWWhEcP2tkWhk1z0GncByOTyThl93cbt5u4+9Mfrk+R9tfJarOboKg58YpMd bqC++L561ME3I6C5IwnBF76zwtwodZceHV7FpSB0XL008KYv6GIbF1DrENj/ttE15mV+ wF5U0UlZ5T1KjgHsFcnNRQxXA1/yaYXCWHp/oBTKVsrLW9RPm6LqYySgrNdRUvHJLkgQ JzgUHjVbWYFrm6Xo/5TjkJte8mqDmZ+W9Nj97z3l3dfis12ad+A2hgiwPVVjEBTGsarM 7nbXIP6iGaqeCoHX6gD72rldEomcyhIEYq0fTi5MHvvrxATGdmXD7oqwFMwspRIdz8r2 JBgw== 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=G7wJo+Wkxu3X8t7D6ANWZKubp5Hy9V004K1Ku7ISNro=; b=sxYCcL13S/LTZwxWfumJadA2Hh0i18xno+hOsT8EXqtXxW1wbBRbWmyKrULj9BG5cx Juqtz8N+wwC1tGyZF67cMxtMhubaI1eqHzObL0cD3vHDoEXzkucZ7GQRg0zcsDnRRpT7 CqOZbfkkZCnOKDfE9xBczmAa4tWdmjFqgEFBeDrjM6Uk0cgiXScO2mJL37FG7Ya8t4PY fdX+ISqRx+7v6xNwlOVE7xyQlhpGhFGJQ0KpWG+1/1f8bt/JGF3IU/HnS4P0Fo1KlyXx 9c7J1QxVHkeQDueyshmP7vYNb3nrZF6paub2hDxhJE/Jf/y121DiUbwo3kGbTyB5LhI8 YWTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G1FrvgfQ; 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 rh14si2234137ejb.210.2021.01.07.06.39.23; Thu, 07 Jan 2021 06:39:46 -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=G1FrvgfQ; 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 S1729663AbhAGOhX (ORCPT + 99 others); Thu, 7 Jan 2021 09:37:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:45880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729173AbhAGOcF (ORCPT ); Thu, 7 Jan 2021 09:32:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9ED69233EA; Thu, 7 Jan 2021 14:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610029893; bh=X6Rf5+F9NCddo6q7+z2kw4bOkqXsMsmKVrRg2mOe4bY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G1FrvgfQXIx9A5uk3bPdRObyrBu+j/JTKnP86rSKFbI45zpe/WSutkaklAglj06PL 2Tfowo9i/F4cfdF4p+XnR2pdZ1ng72wK5u9yNFDSLZb3ZIqETlcMOj8QED/aJ7mZlm 9YIhl51Q4iSRhJF2RpFe1f/Y+2G9AvRUY8VjTfkU= 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 4.14 09/29] vfio/pci: Move dummy_resources_list init in vfio_pci_probe() Date: Thu, 7 Jan 2021 15:31:24 +0100 Message-Id: <20210107143054.267705062@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210107143052.973437064@linuxfoundation.org> References: <20210107143052.973437064@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 6fceefcab81db..dedc7edea5178 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -118,8 +118,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; @@ -1524,6 +1522,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) vdev->irq_type = VFIO_PCI_NUM_IRQS; mutex_init(&vdev->igate); spin_lock_init(&vdev->irqlock); + INIT_LIST_HEAD(&vdev->dummy_resources_list); mutex_init(&vdev->vma_lock); INIT_LIST_HEAD(&vdev->vma_list); init_rwsem(&vdev->memory_lock); -- 2.27.0