diff options
author | Thomas Huth <thuth@redhat.com> | 2019-04-30 21:15:52 +0200 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2019-05-02 16:56:33 +0200 |
commit | aff39be0ed9753c9c323f64a14f5533dd5c43525 (patch) | |
tree | cca49d78c7df6ac7ab137c7139f812b3ec6ef101 /hw/pci-host/xilinx-pcie.c | |
parent | 25ed0ecc0946a50b747fde6c8bce3d0ec99bdeac (diff) | |
download | qemu-aff39be0ed9753c9c323f64a14f5533dd5c43525.zip qemu-aff39be0ed9753c9c323f64a14f5533dd5c43525.tar.gz qemu-aff39be0ed9753c9c323f64a14f5533dd5c43525.tar.bz2 |
hw/pci-host: Use object_initialize_child for correct reference counting
Both functions, object_initialize() and object_property_add_child() increase
the reference counter of the new object, so one of the references has to be
dropped afterwards to get the reference counting right. Otherwise the child
object might not be properly cleaned up when the parent gets destroyed.
Some functions of the pci-host devices miss to drop one of the references.
Fix it by using object_initialize_child() instead, which takes care of
calling object_initialize(), object_property_add_child() and object_unref()
in the right order.
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20190430191552.4027-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'hw/pci-host/xilinx-pcie.c')
-rw-r--r-- | hw/pci-host/xilinx-pcie.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c index 60309af..ceb00e2 100644 --- a/hw/pci-host/xilinx-pcie.c +++ b/hw/pci-host/xilinx-pcie.c @@ -149,8 +149,8 @@ static void xilinx_pcie_host_init(Object *obj) XilinxPCIEHost *s = XILINX_PCIE_HOST(obj); XilinxPCIERoot *root = &s->root; - object_initialize(root, sizeof(*root), TYPE_XILINX_PCIE_ROOT); - object_property_add_child(obj, "root", OBJECT(root), NULL); + object_initialize_child(obj, "root", root, sizeof(*root), + TYPE_XILINX_PCIE_ROOT, &error_abort, NULL); qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(root), "multifunction", false); } |