diff options
author | Wei Jiangang | 2016-03-23 08:26:19 +0100 |
---|---|---|
committer | Michael S. Tsirkin | 2016-04-07 18:57:33 +0200 |
commit | 2e4278b534997d8f33a6e8b7923c168f5e5c89c7 (patch) | |
tree | bded7f4b03e82a070168f094dceb91c877b0d4d4 /hw/pci-bridge/pci_expander_bridge.c | |
parent | virtio: merge virtio_queue_aio_set_host_notifier_handler with virtio_queue_se... (diff) | |
download | qemu-2e4278b534997d8f33a6e8b7923c168f5e5c89c7.tar.gz qemu-2e4278b534997d8f33a6e8b7923c168f5e5c89c7.tar.xz qemu-2e4278b534997d8f33a6e8b7923c168f5e5c89c7.zip |
hw/pci-bridge: Add missing unref in case register-bus fails
The error paths after a successful qdev_create/pci_bus_new
should contain a object_unref/object_unparent.
pxb_dev_init_common() did not yet, so add it.
Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'hw/pci-bridge/pci_expander_bridge.c')
-rw-r--r-- | hw/pci-bridge/pci_expander_bridge.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index 5e7e546b99..ba320bd857 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -249,7 +249,7 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie) PCI_HOST_BRIDGE(ds)->bus = bus; if (pxb_register_bus(dev, bus)) { - return -EINVAL; + goto err_register_bus; } qdev_init_nofail(ds); @@ -263,6 +263,12 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie) pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare); return 0; + +err_register_bus: + object_unref(OBJECT(bds)); + object_unparent(OBJECT(bus)); + object_unref(OBJECT(ds)); + return -EINVAL; } static int pxb_dev_initfn(PCIDevice *dev) |