From: Gavin Shan Date: Mon, 1 Dec 2025 14:17:59 +0000 (+1000) Subject: acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ab76ad7608d4b3da66e4886067b116120433716;p=thirdparty%2Fqemu.git acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors() 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 Signed-off-by: Gavin Shan Reviewed-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Mauro Carvalho Chehab Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-Id: <20251201141803.2386129-2-gshan@redhat.com> --- diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 5445dc11bd..4e6903a8d3 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -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;