snp: fix coverity reported issues
cover snp: fix coverity reported issues
Pankaj Gupta (3):
i386/sev: fix unreachable code coverity issue i386/sev: Move SEV_COMMON null check before dereferencing i386/sev: Return when sev_common is null
target/i386/sev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 i386/sev: fix unreachable code coverity issue
Set 'finish->id_block_en' when block_size read.
coverity #1546887
Fixes 7b34df4426 ("i386/sev: Introduce 'sev-snp-guest' object")
Signed-off-by Pankaj Gupta <[email protected]>
--- target/i386/sev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
target/i386/sev.c +2 -1
@@ -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 *
Signature · 1 line
2.34.1
Re: [PATCH 1/3] i386/sev: fix unreachable code coverity issue
Quoted 5 lines · Pankaj Gupta
Set '
finish->id_block_en' whenblock_sizeread.coverity #1546887
Fixes 7b34df4426 ("i386/sev: Introduce 'sev-snp-guest' object")
Please make that
Fixes Coverity CID 1546887
Fixes 7b34df4426 ("i386/sev: Introduce 'sev-snp-guest' object")
Quoted 1 line
Signed-off-by Pankaj Gupta <[email protected]>
PATCH 2/3 i386/sev: Move SEV_COMMON null check before dereferencing
In reply to Pankaj Guptacoverity #1546886
Fixes 9861405a8f ("i386/sev: Invoke launch_updata_data() for SEV class")
Signed-off-by Pankaj Gupta <[email protected]>
--- target/i386/sev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
target/i386/sev.c +2 -1
@@ -1529,11 +1529,12 @@ int sev_encrypt_flash(hwaddr gpa, uint8_t *ptr, uint64_t len, Error **errp) { SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); -SevCommonStateClass *klass =SEV_COMMON_GET_CLASS (sev_common); +SevCommonStateClass *klass;if (!sev_common) {return 0 ; } + klass =SEV_COMMON_GET_CLASS (sev_common);/* if SEV is in update state then encrypt the data else do nothing */ if (sev_check_state (sev_common,SEV_STATE_LAUNCH_UPDATE )) {
Signature · 1 line
2.34.1
PATCH 3/3 i386/sev: Return when sev_common is null
In reply to Pankaj Guptacoverity #1546885
Fixes 16dcf200dc ("i386/sev: Introduce "sev-common" type to encapsulate common SEV state")
Signed-off-by Pankaj Gupta <[email protected]>
--- target/i386/sev.c | 1 + 1 file changed, 1 insertion(+)
target/i386/sev.c +1 -0
@@ -587,6 +587,7 @@ static SevCapability *sev_get_capabilities(Error **errp) sev_common =SEV_COMMON (MACHINE (qdev_get_machine ())->cgs);if (!sev_common) {error_setg (errp,"SEV is not configured" ); +return NULL ; } sev_device = object_property_get_str(OBJECT(sev_common), "sev-device",
Signature · 1 line
2.34.1
Paolo Bonzini
AppliedQueued, thanks.
Paolo