From 45382dca4ba9acc627a5f3bba7de064a3f54026b Mon Sep 17 00:00:00 2001 From: Zhang Chen Date: Fri, 4 Aug 2023 10:14:30 +0800 Subject: [PATCH] hypervisor/ivshmem: Add ivshmem_dev_lock to protect deinit Add the ivshmem_dev_lock to protect races between release and allocations. Tracked-On: ##8486 Signed-off-by: Zhang Chen Reviewed-by: Junjie Mao --- hypervisor/dm/vpci/ivshmem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hypervisor/dm/vpci/ivshmem.c b/hypervisor/dm/vpci/ivshmem.c index 6efac61b4..7e4247ba1 100644 --- a/hypervisor/dm/vpci/ivshmem.c +++ b/hypervisor/dm/vpci/ivshmem.c @@ -355,9 +355,12 @@ static void deinit_ivshmem_vdev(struct pci_vdev *vdev) struct ivshmem_device *ivs_dev = (struct ivshmem_device *) vdev->priv_data; ivshmem_server_unbind_peer(vdev); - ivs_dev->pcidev = NULL; + + spinlock_obtain(&ivshmem_dev_lock); vdev->priv_data = NULL; vdev->user = NULL; + ivs_dev->pcidev = NULL; + spinlock_release(&ivshmem_dev_lock); } /**