aboutsummaryrefslogtreecommitdiff
path: root/target/i386/sev.c
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2021-10-07 18:17:04 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-10-13 10:47:49 +0200
commited84ae720d0b28c50906412a903e598f75ee1d7c (patch)
tree14deff0e6cc8a1bfcdb0dd973dc9fa4accc7868f /target/i386/sev.c
parentd58d9f55a78a69730b4f1641f1c969d8585b970b (diff)
target/i386/sev: sev_get_attestation_report use g_autofree
Removes a whole bunch of g_free's and a goto. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Connor Kuehl <ckuehl@redhat.com> Reviewed-by: Brijesh Singh <brijesh.singh@amd.com> Message-Id: <20210603113017.34922-1-dgilbert@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20211007161716.453984-12-philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386/sev.c')
-rw-r--r--target/i386/sev.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 9e3f2ec8dd..3a30ba6d94 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -521,8 +521,8 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
struct kvm_sev_attestation_report input = {};
SevAttestationReport *report = NULL;
SevGuestState *sev = sev_guest;
- guchar *data;
- guchar *buf;
+ g_autofree guchar *data = NULL;
+ g_autofree guchar *buf = NULL;
gsize len;
int err = 0, ret;
@@ -542,7 +542,6 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
if (len != sizeof(input.mnonce)) {
error_setg(errp, "SEV: mnonce must be %zu bytes (got %" G_GSIZE_FORMAT ")",
sizeof(input.mnonce), len);
- g_free(buf);
return NULL;
}
@@ -554,7 +553,6 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
error_setg(errp, "SEV: Failed to query the attestation report"
" length ret=%d fw_err=%d (%s)",
ret, err, fw_error_to_str(err));
- g_free(buf);
return NULL;
}
}
@@ -569,7 +567,7 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
if (ret) {
error_setg_errno(errp, errno, "SEV: Failed to get attestation report"
" ret=%d fw_err=%d (%s)", ret, err, fw_error_to_str(err));
- goto e_free_data;
+ return NULL;
}
report = g_new0(SevAttestationReport, 1);
@@ -577,9 +575,6 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
trace_kvm_sev_attestation_report(mnonce, report->data);
-e_free_data:
- g_free(data);
- g_free(buf);
return report;
}