]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors()
authorGavin Shan <gshan@redhat.com>
Mon, 1 Dec 2025 14:17:59 +0000 (00:17 +1000)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 5 Feb 2026 10:06:45 +0000 (05:06 -0500)
Use g_auto_ptr() to automate data block cleanup in the function so
that it won't be a burden to us.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20251201141803.2386129-2-gshan@redhat.com>

hw/acpi/ghes.c

index 5445dc11bdf6d2de24cb5abeb74fcf63ba1d4ad7..4e6903a8d3fedab3bfc22b4672200e2e59c07df2 100644 (file)
@@ -566,9 +566,7 @@ int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id,
                   0xED, 0x7C, 0x83, 0xB1);
     Error *err = NULL;
     int data_length;
-    GArray *block;
-
-    block = g_array_new(false, true /* clear */, 1);
+    g_autoptr(GArray) block = g_array_new(false, true /* clear */, 1);
 
     data_length = ACPI_GHES_DATA_LENGTH + ACPI_GHES_MEM_CPER_LENGTH;
     /*
@@ -586,8 +584,6 @@ int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id,
     /* Report the error */
     ghes_record_cper_errors(ags, block->data, block->len, source_id, &err);
 
-    g_array_free(block, true);
-
     if (err) {
         error_report_err(err);
         return -1;