qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Baron <jbaron@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, alex.williamson@redhat.com,
	aliguori@us.ibm.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] qdev: release parent properties on dc->init failure
Date: Wed, 2 May 2012 22:42:10 -0400	[thread overview]
Message-ID: <f23ddc28aaedc90f361c690f13975178e18a30ef.1336012042.git.jbaron@redhat.com> (raw)
In-Reply-To: <cover.1336012042.git.jbaron@redhat.com>

While looking into hot-plugging bridges, I can create a qemu segfault via:

$ device_add pci-bridge

Bridge chassis not specified. Each bridge is required to be assigned a unique chassis id > 0.
**
ERROR:qom/object.c:389:object_delete: assertion failed: (obj->ref == 0)

I'm proposing to fix this by adding a call to 'object_unparent()', before the
call to qdev_free(). I see there is already a precedent for this usage pattern as
seen in qdev_simple_unplug_cb():

/* can be used as ->unplug() callback for the simple cases */
int qdev_simple_unplug_cb(DeviceState *dev)
{
    /* just zap it */
    object_unparent(OBJECT(dev));
    qdev_free(dev);
    return 0;
}

Signed-off-by: Jason Baron <jbaron@redhat.com>
---
 hw/qdev.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 0bcde20..cff7f4c 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -150,6 +150,7 @@ int qdev_init(DeviceState *dev)
 
     rc = dc->init(dev);
     if (rc < 0) {
+        object_unparent(OBJECT(dev));
         qdev_free(dev);
         return rc;
     }
-- 
1.7.1

  reply	other threads:[~2012-05-03  2:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03  2:42 [Qemu-devel] [PATCH 0/2] pci: hotplug bridge fixes Jason Baron
2012-05-03  2:42 ` Jason Baron [this message]
2012-05-03  2:42 ` [Qemu-devel] [PATCH 2/2] pci_bridge_dev: fix error path in pci_bridge_dev_initfn() Jason Baron
2012-06-04 21:47 ` [Qemu-devel] [PATCH 0/2] pci: hotplug bridge fixes Michael S. Tsirkin

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=f23ddc28aaedc90f361c690f13975178e18a30ef.1336012042.git.jbaron@redhat.com \
    --to=jbaron@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@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).