From: Gavin Shan <gshan@redhat.com>
To: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org, mst@redhat.com,
jonathan.cameron@huawei.com, mchehab+huawei@kernel.org,
imammedo@redhat.com, armbru@redhat.com, anisinha@redhat.com,
gengdongjiu1@gmail.com, peter.maydell@linaro.org,
pbonzini@redhat.com, shan.gavin@gmail.com
Subject: [PATCH v2 1/5] acpi/ghes: Automate data block cleanup in acpi_ghes_memory_errors()
Date: Tue, 2 Dec 2025 00:17:59 +1000 [thread overview]
Message-ID: <20251201141803.2386129-2-gshan@redhat.com> (raw)
In-Reply-To: <20251201141803.2386129-1-gshan@redhat.com>
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>
---
hw/acpi/ghes.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c
index 06555905ce..6366c74248 100644
--- a/hw/acpi/ghes.c
+++ b/hw/acpi/ghes.c
@@ -565,9 +565,7 @@ int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id,
0xED, 0x7C, 0x83, 0xB1);
Error *errp = 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;
/*
@@ -585,8 +583,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, &errp);
- g_array_free(block, true);
-
if (errp) {
error_report_err(errp);
return -1;
--
2.51.1
next prev parent reply other threads:[~2025-12-01 14:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 14:17 [PATCH v2 0/5] acpi/ghes: Error object handling improvement Gavin Shan
2025-12-01 14:17 ` Gavin Shan [this message]
2025-12-01 14:18 ` [PATCH v2 2/5] acpi/ghes: Abort in acpi_ghes_memory_errors() if necessary Gavin Shan
2025-12-01 14:18 ` [PATCH v2 3/5] target/arm/kvm: Exit on error from acpi_ghes_memory_errors() Gavin Shan
2025-12-01 14:18 ` [PATCH v2 4/5] acpi/ghes: Bail early on error from get_ghes_source_offsets() Gavin Shan
2025-12-01 14:18 ` [PATCH v2 5/5] acpi/ghes: Use error_fatal in acpi_ghes_memory_errors() Gavin Shan
2025-12-04 11:09 ` [PATCH v2 0/5] acpi/ghes: Error object handling improvement Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251201141803.2386129-2-gshan@redhat.com \
--to=gshan@redhat.com \
--cc=anisinha@redhat.com \
--cc=armbru@redhat.com \
--cc=gengdongjiu1@gmail.com \
--cc=imammedo@redhat.com \
--cc=jonathan.cameron@huawei.com \
--cc=mchehab+huawei@kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shan.gavin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).