Hi Paolo,

On 6/10/23 01:04, Paolo Bonzini wrote:
On 10/3/23 10:27, Philippe Mathieu-Daudé wrote:
-    /* TODO: convert to link<> */
-    apic = APIC_COMMON(cpu->apic_state);
-    apic->cpu = cpu;
-    apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE;
+    qdev_prop_set_uint32(cpu->apic_state, "base-addr",
+                         APIC_DEFAULT_ADDRESS | MSR_IA32_APIC

For this to use a link, it's missing the corresponding object_unref(apic->cpu) + apic->cpu = NULL assignment somewhere.  For example you can add it in apic_common_unrealize (called by device_unparent - which is called in turn by x86_cpu_unrealizefn).

I am a bit confused.

DEFINE_PROP_LINK() sets OBJ_PROP_LINK_STRONG:

 * If the link property was created with
 * %OBJ_PROP_LINK_STRONG bit, the old target object is
 * unreferenced, and a reference is added to the new target object.

Is this what you are pointing at? If so, I agree this should be
unref in apic_common_unrealize().

Reply via email to