]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/arm/virt: fix cpu object reference leak
authorIgor Mammedov <imammedo@redhat.com>
Tue, 28 Feb 2017 12:08:15 +0000 (12:08 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 28 Feb 2017 12:08:15 +0000 (12:08 +0000)
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: Igor Mammedov <imammedo@redhat.com>
Message-id: 1487253461-269218-1-git-send-email-imammedo@redhat.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/arm/virt.c

index f3440f2ccbb0c67fa2d4156a7b39982eebb04b5e..0c270b8919de078631fe5ec44236d40dc70cc3f7 100644 (file)
@@ -1378,6 +1378,7 @@ static void machvirt_init(MachineState *machine)
         }
 
         object_property_set_bool(cpuobj, true, "realized", NULL);
+        object_unref(cpuobj);
     }
     fdt_add_timer_nodes(vms);
     fdt_add_cpu_nodes(vms);