提交 dbb74759 编写于 作者: I Igor Mammedov 提交者: Peter Maydell

hw/arm/virt: fix cpu object reference leak

object_new(FOO) returns an object with ref_cnt == 1
and following
  object_property_set_bool(cpuobj, true, "realized", NULL)
set parent of cpuobj to '/machine/unattached' which makes
ref_cnt == 2.

Since machvirt_init() doesn't take ownership of cpuobj
returned by object_new() it should explicitly drop
reference to cpuobj when dangling pointer is about to
go out of scope like it's done pc_new_cpu() to avoid
object leak.
Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
Message-id: 1487253461-269218-1-git-send-email-imammedo@redhat.com
Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
上级 241999bf
...@@ -1378,6 +1378,7 @@ static void machvirt_init(MachineState *machine) ...@@ -1378,6 +1378,7 @@ static void machvirt_init(MachineState *machine)
} }
object_property_set_bool(cpuobj, true, "realized", NULL); object_property_set_bool(cpuobj, true, "realized", NULL);
object_unref(cpuobj);
} }
fdt_add_timer_nodes(vms); fdt_add_timer_nodes(vms);
fdt_add_cpu_nodes(vms); fdt_add_cpu_nodes(vms);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册