From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Brijesh Singh" <brijesh.singh@amd.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Sergio Lopez" <slp@redhat.com>,
"James Bottomley" <jejb@linux.ibm.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Dov Murik" <dovmurik@linux.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH v4 12/23] target/i386/sev: Use g_autofree in sev_launch_get_measure()
Date: Thu, 7 Oct 2021 18:17:05 +0200 [thread overview]
Message-ID: <20211007161716.453984-13-philmd@redhat.com> (raw)
In-Reply-To: <20211007161716.453984-1-philmd@redhat.com>
Use g_autofree to remove a pair of g_free/goto.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
target/i386/sev.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 3a30ba6d94a..5cbbcf0bb93 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -685,8 +685,8 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
{
SevGuestState *sev = sev_guest;
int ret, error;
- guchar *data;
- struct kvm_sev_launch_measure *measurement;
+ g_autofree guchar *data = NULL;
+ g_autofree struct kvm_sev_launch_measure *measurement = NULL;
if (!sev_check_state(sev, SEV_STATE_LAUNCH_UPDATE)) {
return;
@@ -708,7 +708,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
if (!measurement->len) {
error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
__func__, ret, error, fw_error_to_str(errno));
- goto free_measurement;
+ return;
}
data = g_new0(guchar, measurement->len);
@@ -720,7 +720,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
if (ret) {
error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
__func__, ret, error, fw_error_to_str(errno));
- goto free_data;
+ return;
}
sev_set_guest_state(sev, SEV_STATE_LAUNCH_SECRET);
@@ -728,11 +728,6 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
/* encode the measurement value and emit the event */
sev->measurement = g_base64_encode(data, measurement->len);
trace_kvm_sev_launch_measurement(sev->measurement);
-
-free_data:
- g_free(data);
-free_measurement:
- g_free(measurement);
}
char *
--
2.31.1
next prev parent reply other threads:[~2021-10-07 16:24 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 16:16 [PATCH v4 00/23] target/i386/sev: Housekeeping SEV + measured Linux SEV guest Philippe Mathieu-Daudé
2021-10-07 16:16 ` [PATCH v4 01/23] qapi/misc-target: Wrap long 'SEV Attestation Report' long lines Philippe Mathieu-Daudé
2021-10-07 16:16 ` [PATCH v4 02/23] qapi/misc-target: Group SEV QAPI definitions Philippe Mathieu-Daudé
2021-10-07 16:16 ` [PATCH v4 03/23] target/i386/kvm: Introduce i386_softmmu_kvm Meson source set Philippe Mathieu-Daudé
2021-10-07 16:16 ` [PATCH v4 04/23] target/i386/kvm: Restrict SEV stubs to x86 architecture Philippe Mathieu-Daudé
2021-10-07 16:16 ` [PATCH v4 05/23] target/i386/sev: Prefix QMP errors with 'SEV' Philippe Mathieu-Daudé
2021-10-07 16:23 ` Dr. David Alan Gilbert
2021-10-07 16:16 ` [PATCH v4 06/23] target/i386/monitor: Return QMP error when SEV is not enabled for guest Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 07/23] target/i386/cpu: Add missing 'qapi/error.h' header Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 08/23] target/i386/sev_i386.h: Remove unused headers Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 09/23] target/i386/sev: Remove sev_get_me_mask() Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 10/23] target/i386/sev: Mark unreachable code with g_assert_not_reached() Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 11/23] target/i386/sev: sev_get_attestation_report use g_autofree Philippe Mathieu-Daudé
2021-10-07 16:17 ` Philippe Mathieu-Daudé [this message]
2021-10-07 16:28 ` [PATCH v4 12/23] target/i386/sev: Use g_autofree in sev_launch_get_measure() Dov Murik
2021-10-12 6:15 ` Dov Murik
2021-10-07 16:17 ` [PATCH v4 13/23] target/i386/sev: Restrict SEV to system emulation Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 14/23] target/i386/sev: Rename sev_i386.h -> sev.h Philippe Mathieu-Daudé
2021-10-07 16:32 ` Dr. David Alan Gilbert
2021-10-07 16:17 ` [PATCH v4 15/23] target/i386/sev: Declare system-specific functions in 'sev.h' Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 16/23] target/i386/sev: Remove stubs by using code elision Philippe Mathieu-Daudé
2021-10-07 17:07 ` Dr. David Alan Gilbert
2021-10-07 17:18 ` Philippe Mathieu-Daudé
2021-10-07 17:22 ` Dr. David Alan Gilbert
2021-10-08 11:46 ` Paolo Bonzini
2021-10-07 17:27 ` Daniel P. Berrangé
2021-10-07 19:51 ` Eric Blake
2021-10-07 16:17 ` [PATCH v4 17/23] target/i386/sev: Move qmp_query_sev_attestation_report() to sev.c Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 18/23] target/i386/sev: Move qmp_sev_inject_launch_secret() " Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 19/23] target/i386/sev: Move qmp_query_sev_capabilities() " Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 20/23] target/i386/sev: Move qmp_query_sev_launch_measure() " Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 21/23] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() " Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 22/23] monitor: Reduce hmp_info_sev() declaration Philippe Mathieu-Daudé
2021-10-07 16:17 ` [PATCH v4 23/23] MAINTAINERS: Cover SEV-related files with X86/KVM section Philippe Mathieu-Daudé
2021-10-07 16:22 ` Philippe Mathieu-Daudé
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=20211007161716.453984-13-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=brijesh.singh@amd.com \
--cc=dgilbert@redhat.com \
--cc=dovmurik@linux.ibm.com \
--cc=ehabkost@redhat.com \
--cc=jejb@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=slp@redhat.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).