object_new_with_class() and object_property_add_child() leave a reference count
of two while the QOM root is the sole owner. Fix the reference count to be one
by calling object_unref() once.

Signed-off-by: Bernhard Beschow <[email protected]>
---
 system/vl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/system/vl.c b/system/vl.c
index 38d7b849e0..91b390dafd 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2197,6 +2197,7 @@ static void qemu_create_machine(QDict *qdict)
     current_machine = 
MACHINE(object_new_with_class(OBJECT_CLASS(machine_class)));
     object_property_add_child(object_get_root(), "machine",
                               OBJECT(current_machine));
+    object_unref(current_machine);
     qemu_create_machine_containers(OBJECT(current_machine));
     object_property_add_child(machine_get_container("unattached"),
                               "sysbus", OBJECT(sysbus_get_default()));
-- 
2.53.0


Reply via email to