diff options
author | Philippe Mathieu-Daudé <philmd@redhat.com> | 2021-10-07 18:17:05 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-10-13 10:47:49 +0200 |
commit | 2f573c415e8c84ec79aa6deb1d04fa9fccdebca7 (patch) | |
tree | 6282f93b0b403abed1edd96774c90f51df0ff116 /target/i386/sev.c | |
parent | ed84ae720d0b28c50906412a903e598f75ee1d7c (diff) | |
download | qemu-2f573c415e8c84ec79aa6deb1d04fa9fccdebca7.zip qemu-2f573c415e8c84ec79aa6deb1d04fa9fccdebca7.tar.gz qemu-2f573c415e8c84ec79aa6deb1d04fa9fccdebca7.tar.bz2 |
target/i386/sev: Use g_autofree in sev_launch_get_measure()
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>
Diffstat (limited to 'target/i386/sev.c')
-rw-r--r-- | target/i386/sev.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/target/i386/sev.c b/target/i386/sev.c index 3a30ba6..5cbbcf0 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 * |