[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1.3 1/5] qom: fix refcount of non-heap-allocated obj
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 1.3 1/5] qom: fix refcount of non-heap-allocated objects |
Date: |
Fri, 23 Nov 2012 09:47:12 +0100 |
The reference count for embedded objects is always one too low, because
object_initialize_with_type returns with zero references to the object.
This causes premature finalization of the object (or an assertion failure)
after calling object_ref to add an extra reference and object_unref to
remove it.
The fix is to move the initial object_ref call from object_new_with_type
to object_initialize_with_type.
Signed-off-by: Paolo Bonzini <address@hidden>
---
qom/object.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qom/object.c b/qom/object.c
index d7092b0..6a8c02a 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -307,6 +307,7 @@ void object_initialize_with_type(void *data, TypeImpl *type)
memset(obj, 0, type->instance_size);
obj->class = type->class;
+ object_ref(obj);
QTAILQ_INIT(&obj->properties);
object_init_with_type(obj, type);
}
@@ -395,7 +396,6 @@ Object *object_new_with_type(Type type)
obj = g_malloc(type->instance_size);
object_initialize_with_type(obj, type);
- object_ref(obj);
return obj;
}
--
1.8.0
- [Qemu-devel] [PATCH 1.3 0/5] QOM/qdev lifetime fixes, Paolo Bonzini, 2012/11/23
- [Qemu-devel] [PATCH 1.3 4/5] qdev: simplify (de)allocation of buses, Paolo Bonzini, 2012/11/23
- [Qemu-devel] [PATCH 1.3 2/5] qdev: move bus removal to object_unparent, Paolo Bonzini, 2012/11/23
- [Qemu-devel] [PATCH 1.3 1/5] qom: fix refcount of non-heap-allocated objects,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 1.3 3/5] qom: make object_delete usable for statically-allocated objects, Paolo Bonzini, 2012/11/23
- [Qemu-devel] [PATCH 1.3 5/5] qom: make object_finalize static, Paolo Bonzini, 2012/11/23
- Re: [Qemu-devel] [PATCH 1.3 0/5] QOM/qdev lifetime fixes, Anthony Liguori, 2012/11/26