[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/23] target/i386/sev: sev_get_attestation_report use g_autof
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 09/23] target/i386/sev: sev_get_attestation_report use g_autofree |
Date: |
Wed, 16 Jun 2021 22:43:14 +0200 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
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>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
target/i386/sev.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 0a36e81f66c..791804954e9 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -493,8 +493,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;
@@ -514,7 +514,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;
}
@@ -525,7 +524,6 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
if (err != SEV_RET_INVALID_LEN) {
error_setg(errp, "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;
}
}
@@ -540,7 +538,7 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
if (ret) {
error_setg_errno(errp, errno, "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);
@@ -548,9 +546,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;
}
--
2.31.1
- [PATCH v2 00/23] target/i386/sev: Housekeeping (OVMF + SEV-disabled binaries), Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 02/23] qapi/misc-target: Wrap long 'SEV Attestation Report' long lines, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 01/23] MAINTAINERS: Add Connor Kuehl as reviewer for AMD SEV, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 03/23] qapi/misc-target: Group SEV QAPI definitions, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 05/23] target/i386/cpu: Add missing 'qapi/error.h' header, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 04/23] target/i386/monitor: Return QMP error when SEV is disabled in build, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 06/23] target/i386/sev_i386.h: Remove unused headers, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 07/23] target/i386/sev: Remove sev_get_me_mask(), Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 08/23] target/i386/sev: Mark unreachable code with g_assert_not_reached(), Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 09/23] target/i386/sev: sev_get_attestation_report use g_autofree,
Philippe Mathieu-Daudé <=
- [PATCH v2 10/23] target/i386/sev: Restrict SEV to system emulation, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 11/23] target/i386/sev: Move qmp_query_sev_attestation_report() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 12/23] target/i386/sev: Move qmp_sev_inject_launch_secret() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 13/23] target/i386/sev: Move qmp_query_sev_capabilities() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 14/23] target/i386/sev: Move qmp_query_sev_launch_measure() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 15/23] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 16/23] monitor: Restrict 'info sev' to x86 targets, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 17/23] hw/i386/acpi-common: Remove unused includes, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 18/23] hw/i386: Rename acpi-build.c -> acpi-pc.c, Philippe Mathieu-Daudé, 2021/06/16
- [PATCH v2 20/23] hw/acpi: Do not restrict ACPI core routines to x86 architecture, Philippe Mathieu-Daudé, 2021/06/16