@samitouri / QOSamiQemu / commits / 5e8d44971e

hw/hexagon: fix machine->fdt leak in qom-test

virt_instance_init() built the FDT unconditionally at QOM instance-init time, so simply instantiating the object (e.g. via qom-test's introspection, without ever realizing the machine) leaked the 1MB FDT blob: machine_finalize() does not free machine->fdt. Other boards (arm/virt, riscv/virt, ...) build the FDT lazily from their MachineClass::init callback, which only runs when the machine is actually selected to boot. Do the same here by moving create_fdt() into virt_init(). Fixes: 88a8bc7f43ff ("hw/hexagon: Define hexagon "virt" machine") Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Jul 21, 2026 at 23:46 UTC 5e8d44971ed362c5f517547ed24d82b101f96171
1 file changed +1 -8
hw/hexagon/virt.c
+1 -8
@@ -175,13 +175,6 @@ static void fdt_add_cpu_nodes(const HexagonVirtMachineState *vms)
175
176
177
178 -static void virt_instance_init(Object *obj)
179 -{
180 - HexagonVirtMachineState *vms = HEXAGON_VIRT_MACHINE(obj);
181 -
182 - create_fdt(vms);
183 -}
184 -
178 void hexagon_load_fdt(const HexagonVirtMachineState *vms)
179 {
180 MachineState *ms = MACHINE(vms);
@@ -242,6 +235,7 @@ static void virt_init(MachineState *ms)
235 DeviceState *cpu0;
236 int32_t clk_phandle;
237
238 + create_fdt(vms);
239 qemu_fdt_setprop_string(ms->fdt, "/chosen", "bootargs", ms->kernel_cmdline);
240
241 vms->sys = get_system_memory();
@@ -341,7 +335,6 @@ static const TypeInfo virt_machine_types[] = { {
335 .parent = TYPE_HEXAGON_COMMON_MACHINE,
336 .instance_size = sizeof(HexagonVirtMachineState),
337 .class_init = virt_class_init,
344 - .instance_init = virt_instance_init,
338 } };
339
340 DEFINE_TYPES(virt_machine_types)