]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/arm/aspeed: free fmc_model and spi_model on finalization
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 27 Apr 2026 12:05:25 +0000 (16:05 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 11 May 2026 19:59:33 +0000 (23:59 +0400)
The fmc_model and spi_model strings are allocated via g_strdup in
property setters but never freed when the machine object is destroyed.

Fixes: 9820e52fbef7 ("hw/arm/aspeed: Add machine properties to define the flash models")
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
hw/arm/aspeed.c

index a3db3406c5f779cfb12866ac78782ababf4a795b..a48c442058378f057dbab41b772b328ba622a569 100644 (file)
@@ -419,12 +419,21 @@ static void aspeed_machine_class_init(ObjectClass *oc, const void *data)
     aspeed_machine_class_props_init(oc);
 }
 
+static void aspeed_machine_instance_finalize(Object *obj)
+{
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    g_free(bmc->fmc_model);
+    g_free(bmc->spi_model);
+}
+
 static const TypeInfo aspeed_machine_types[] = {
     {
         .name          = TYPE_ASPEED_MACHINE,
         .parent        = TYPE_MACHINE,
         .instance_size = sizeof(AspeedMachineState),
         .instance_init = aspeed_machine_instance_init,
+        .instance_finalize = aspeed_machine_instance_finalize,
         .class_size    = sizeof(AspeedMachineClass),
         .class_init    = aspeed_machine_class_init,
         .abstract      = true,