From 98057e3adafa052b21a4fe5ef22835d30df3e644 Mon Sep 17 00:00:00 2001 From: Pankaj Gupta Date: Fri, 7 Jun 2024 13:36:09 -0500 Subject: [PATCH 084/100] i386/sev: fix unreachable code coverity issue RH-Author: Paolo Bonzini RH-MergeRequest: 245: SEV-SNP support RH-Jira: RHEL-39544 RH-Acked-by: Thomas Huth RH-Acked-by: Bandan Das RH-Acked-by: Vitaly Kuznetsov RH-Commit: [84/91] dc7bf28f491bf675b22a98ea593fba72d8bc415a (bonzini/rhel-qemu-kvm) Set 'finish->id_block_en' early, so that it is properly reset. Fixes coverity CID 1546887. Fixes: 7b34df4426 ("i386/sev: Introduce 'sev-snp-guest' object") Signed-off-by: Pankaj Gupta Message-ID: <20240607183611.1111100-2-pankaj.gupta@amd.com> Signed-off-by: Paolo Bonzini (cherry picked from commit c94eb5db8e409c932da9eb187e68d4cdc14acc5b) Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 004c667ac1..7c9df621de 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -2165,6 +2165,7 @@ sev_snp_guest_set_id_block(Object *obj, const char *value, Error **errp) struct kvm_sev_snp_launch_finish *finish = &sev_snp_guest->kvm_finish_conf; gsize len; + finish->id_block_en = 0; g_free(sev_snp_guest->id_block); g_free((guchar *)finish->id_block_uaddr); @@ -2184,7 +2185,7 @@ sev_snp_guest_set_id_block(Object *obj, const char *value, Error **errp) return; } - finish->id_block_en = (len) ? 1 : 0; + finish->id_block_en = 1; } static char * -- 2.39.3