target/i386: Fix dereferencing before null check
PATCH 1/1 target/i386: Fix dereferencing before null check
The 'sev_common' pointer is dereferenced via SEV_COMMON_GET_CLASS() before it is checked for NULL.
Fix this by moving the NULL check to the beginning of the function before any dereferencing occurs.
Resolves: CID 1645467
Signed-off-by Trieu Huynh <[email protected]>
--- target/i386/sev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/i386/sev.c +1 -2
@@ -2009,11 +2009,10 @@ static int sev_snp_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)static void sev_handle_reset (Object *obj,ResetType type) {SevCommonState *sev_common =SEV_COMMON (MACHINE (qdev_get_machine ())->cgs); -SevCommonStateClass *klass =SEV_COMMON_GET_CLASS (sev_common); -if (!sev_common) {return ; } +SevCommonStateClass *klass =SEV_COMMON_GET_CLASS (sev_common);if (!runstate_is_running ()) {return ;
Signature · 1 line
2.43.0