pcie: Release references of virtual functions
authorAkihiko Odaki <akihiko.odaki@daynix.com>
Tue, 11 Apr 2023 09:04:08 +0000 (18:04 +0900)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 10 Jul 2023 22:59:32 +0000 (18:59 -0400)
pci_new() automatically retains a reference to a virtual function when
registering it so we need to release the reference when unregistering.

Fixes: 7c0fa8dff8 ("pcie: Add support for Single Root I/O Virtualization (SR/IOV)")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230411090408.48366-1-akihiko.odaki@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
hw/pci/pcie_sriov.c

index aa5a757b1125b6f90ffd6e28a3007d403eaa0afa..76a3b6917e60a3b35312d01e850e6a00a6d997f1 100644 (file)
@@ -211,6 +211,7 @@ static void unregister_vfs(PCIDevice *dev)
             error_free(local_err);
         }
         object_unparent(OBJECT(vf));
+        object_unref(OBJECT(vf));
     }
     g_free(dev->exp.sriov_pf.vf);
     dev->exp.sriov_pf.vf = NULL;