Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9092443pxu; Mon, 28 Dec 2020 06:27:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKZjKCRhP4/c3dt29PLnVpvxlmZ6ZMTgGB01pOI8zpjue9doZsEOGIVpWPw7rbdRo4o+4N X-Received: by 2002:aa7:d999:: with SMTP id u25mr41832629eds.297.1609165640111; Mon, 28 Dec 2020 06:27:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165640; cv=none; d=google.com; s=arc-20160816; b=mLGf4ga4+Zig7mYTuKqUl5AKPwCsP4mG5PMu54gVxUoIbFr0kEtGfZsX0PANds2GzV pOQNIAg+lM8mdqgDX95RIV2STiGyyCquJPRQsFCpnzxhDfKnlntWcOsgj3cBpzT7oJc1 0kCuwaVISHff9WoQZSsByEJ+7epxVq4LLyMbTpUeeAqN2XufxuZ/4TWSiVYEIzQ2QnOz fBgHNVaRkFB536rxQRUZdgia2J9Olib4q9fTsU4x/9uJkn+5oDKGOxWDfB/kcwNlohYE vxCyn2XEG7UF5lJDBds/cSFPShGi9d7WsvDskjEuo/fskBWo0XEjvj/OgVTxsxPxr4mQ X0CQ== 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=cYYlD3gPNeRWmEcLNT/TsaX4YjP68DcZ88DYIQI3QrE=; b=FhLsH0rHFUqF47+GkCqq0AApwF7KbSNgXkuPa+vddR5/PKupAMptezEyjg/ODTPf2x DRBwtDMrXq3qPXBOlHXckXr0cKKsGc7xbV9OP2Xd3kx+EQ+fiKiIyAR/Z4dVc/Bc2lhU nhyvi2qGWfH8kkevnC8Q8tCSOHRdPlkOZAtI4ULsJ69jkjf0tP5umndy0JRBS920oDB2 j/FZ89/N07QsxBbFXHg+qkj/pMYjLX+JRTfFqUwzsU5Yx9O3hzzBSxpiTIA7TCCUa50V zdQbsL6TjZ3H3ymSs90saEL31wFul0t2HRuYeXa1V4LjYqJtr8JyLtoX/vxcqj9KWeI6 wKZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YySZkF4a; 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 lo18si10737842ejb.108.2020.12.28.06.26.56; Mon, 28 Dec 2020 06:27:20 -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=YySZkF4a; 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 S2503143AbgL1OYv (ORCPT + 99 others); Mon, 28 Dec 2020 09:24:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:60270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503131AbgL1OYq (ORCPT ); Mon, 28 Dec 2020 09:24:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2707C20791; Mon, 28 Dec 2020 14:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165471; bh=EWLUgXL++eCggRttILvYyI17z+cKJUg0l/kJ0Nht58E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YySZkF4a+RXdimG0ac7ZxWi41dAb1oCL9W5GFWZOlFJ3Q6WoChla+Hcpjw6ndmgeB YGUBk7zJY8e0RjSdQvNa0vDXD8bQeXrdDSjT3z3BWgzGjCMaWMVnc8rmq3TPQUK1wZ 5757chbHKxMkPoYetFuqBfPJJ/UZ7v8m8+bTCs3E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Auger , Alex Williamson Subject: [PATCH 5.10 513/717] vfio/pci: Move dummy_resources_list init in vfio_pci_probe() Date: Mon, 28 Dec 2020 13:48:31 +0100 Message-Id: <20201228125045.549457581@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 commit 16b8fe4caf499ae8e12d2ab1b1324497e36a7b83 upstream. 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: Greg Kroah-Hartman --- drivers/vfio/pci/vfio_pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -161,8 +161,6 @@ static void vfio_pci_probe_mmaps(struct int i; struct vfio_pci_dummy_resource *dummy_res; - INIT_LIST_HEAD(&vdev->dummy_resources_list); - for (i = 0; i < PCI_STD_NUM_BARS; i++) { int bar = i + PCI_STD_RESOURCES; @@ -1966,6 +1964,7 @@ static int vfio_pci_probe(struct pci_dev 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);