vPCI MMIO handlers are accessing pdevs without protecting this access with pcidevs_{lock|unlock}. This is not a problem as of now as these are only used by Dom0. But, towards vPCI is used also for guests, we need to properly protect pdev and pdev->vpci from being removed while still in use.
For that use pdev reference counting. Signed-off-by: Volodymyr Babchuk <volodymyr_babc...@epam.com> Suggested-by: Jan Beulich <jbeul...@suse.com> --- v3: - Moved from another patch series --- xen/drivers/vpci/vpci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index 199ff55672..005f38dc77 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -62,6 +62,7 @@ void vpci_remove_device(struct pci_dev *pdev) xfree(pdev->vpci->msi); xfree(pdev->vpci); pdev->vpci = NULL; + pcidev_put(pdev); } int vpci_add_handlers(struct pci_dev *pdev) @@ -72,6 +73,8 @@ int vpci_add_handlers(struct pci_dev *pdev) if ( !has_vpci(pdev->domain) ) return 0; + pcidev_get(pdev); + /* We should not get here twice for the same device. */ ASSERT(!pdev->vpci); -- 2.39.2