public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH] target/i386: Fix dereferencing before null check
@ 2026-03-12 12:37 Trieu Huynh
  0 siblings, 0 replies; only message in thread
From: Trieu Huynh @ 2026-03-12 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Trieu Huynh, Paolo Bonzini, Marcelo Tosatti, Zhao Liu, kvm

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 <vikingtc4@gmail.com>
---
 target/i386/sev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/target/i386/sev.c b/target/i386/sev.c
index cddffe0da8..d23694e05b 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -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;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-12 12:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 12:37 [PATCH] target/i386: Fix dereferencing before null check Trieu Huynh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox