[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/40] target/i386/sev: Use g_autofree in sev_launch_get_measure()
From: |
Paolo Bonzini |
Subject: |
[PULL 17/40] target/i386/sev: Use g_autofree in sev_launch_get_measure() |
Date: |
Wed, 13 Oct 2021 11:07:05 +0200 |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
Use g_autofree to remove a pair of g_free/goto.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20211007161716.453984-13-philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@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 3a30ba6d94..5cbbcf0bb9 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
- [PULL 02/40] tests: add missing dependency for check-block, (continued)
- [PULL 02/40] tests: add missing dependency for check-block, Paolo Bonzini, 2021/10/13
- [PULL 01/40] MAINTAINERS: Add myself as reviewer of the 'Memory API', Paolo Bonzini, 2021/10/13
- [PULL 09/40] target/i386/kvm: Restrict SEV stubs to x86 architecture, Paolo Bonzini, 2021/10/13
- [PULL 04/40] qemu-iotests: flush after every test, Paolo Bonzini, 2021/10/13
- [PULL 08/40] target/i386/kvm: Introduce i386_softmmu_kvm Meson source set, Paolo Bonzini, 2021/10/13
- [PULL 20/40] target/i386/sev: Declare system-specific functions in 'sev.h', Paolo Bonzini, 2021/10/13
- [PULL 05/40] util/compatfd.c: use libc signalfd wrapper instead of raw syscall, Paolo Bonzini, 2021/10/13
- [PULL 03/40] build: fix "make check" without earlier "make", Paolo Bonzini, 2021/10/13
- [PULL 07/40] qapi/misc-target: Group SEV QAPI definitions, Paolo Bonzini, 2021/10/13
- [PULL 10/40] target/i386/sev: Prefix QMP errors with 'SEV', Paolo Bonzini, 2021/10/13
- [PULL 17/40] target/i386/sev: Use g_autofree in sev_launch_get_measure(),
Paolo Bonzini <=
- [PULL 22/40] target/i386/sev: Move qmp_query_sev_attestation_report() to sev.c, Paolo Bonzini, 2021/10/13
- [PULL 06/40] qapi/misc-target: Wrap long 'SEV Attestation Report' long lines, Paolo Bonzini, 2021/10/13
- [PULL 11/40] target/i386/monitor: Return QMP error when SEV is not enabled for guest, Paolo Bonzini, 2021/10/13
- [PULL 14/40] target/i386/sev: Remove sev_get_me_mask(), Paolo Bonzini, 2021/10/13
- [PULL 19/40] target/i386/sev: Rename sev_i386.h -> sev.h, Paolo Bonzini, 2021/10/13
- [PULL 25/40] target/i386/sev: Move qmp_query_sev_launch_measure() to sev.c, Paolo Bonzini, 2021/10/13
- [PULL 15/40] target/i386/sev: Mark unreachable code with g_assert_not_reached(), Paolo Bonzini, 2021/10/13
- [PULL 21/40] target/i386/sev: Remove stubs by using code elision, Paolo Bonzini, 2021/10/13
- [PULL 26/40] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c, Paolo Bonzini, 2021/10/13
- [PULL 28/40] MAINTAINERS: Cover SEV-related files with X86/KVM section, Paolo Bonzini, 2021/10/13