From: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: marcel@redhat.com, caoj.fnst@cn.fujitsu.com,
Wei Jiangang <weijg.fnst@cn.fujitsu.com>,
armbru@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH v3 1/2] hw/pci-bridge: Add missing unref in case register-bus fails
Date: Wed, 23 Mar 2016 18:08:43 +0800 [thread overview]
Message-ID: <1458727724-5538-2-git-send-email-weijg.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1458727724-5538-1-git-send-email-weijg.fnst@cn.fujitsu.com>
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)
--
1.9.3
next prev parent reply other threads:[~2016-03-23 10:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-23 10:08 [Qemu-devel] [PATCH v3 0/2] Convert pxb initfn to Error Wei Jiangang
2016-03-23 10:08 ` Wei Jiangang [this message]
2016-03-23 10:08 ` [Qemu-devel] [PATCH v3 2/2] hw/pci-bridge: Convert pxb initialization functions " Wei Jiangang
2016-03-23 12:05 ` Markus Armbruster
2016-03-24 0:40 ` Wei, Jiangang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458727724-5538-2-git-send-email-weijg.fnst@cn.fujitsu.com \
--to=weijg.fnst@cn.fujitsu.com \
--cc=armbru@redhat.com \
--cc=caoj.fnst@cn.fujitsu.com \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).