Message ID | 1458717980-26686-2-git-send-email-weijg.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 03/23/2016 09:26 AM, Wei Jiangang wrote: > 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> > --- > hw/pci-bridge/pci_expander_bridge.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c > index 5e7e546..ba320bd 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) > Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Thanks, Marcel
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index 5e7e546..ba320bd 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)