[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 16/16] hw/i386/vmport: Assert vmport initialized before regist

From: Liran Alon
Subject: [PATCH v3 16/16] hw/i386/vmport: Assert vmport initialized before registering commands
Date: Thu, 12 Mar 2020 18:54:31 +0200

vmport_register() is also called from other modules such as vmmouse.
Therefore, these modules rely that vmport is realized before those call
sites. If this is violated, vmport_register() will NULL-deref.

To make such issues easier to debug, assert in vmport_register() that
vmport is already realized.

Reviewed-by: Nikita Leshenko <address@hidden>
Signed-off-by: Liran Alon <address@hidden>
 hw/i386/vmport.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c
index 9d3921cf418d..134d793a4c65 100644
--- a/hw/i386/vmport.c
+++ b/hw/i386/vmport.c
@@ -83,6 +83,8 @@ static VMPortState *port_state;
 void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *opaque)
     assert(command < VMPORT_ENTRIES);
+    assert(port_state);
     trace_vmport_register(command, func, opaque);
     port_state->func[command] = func;
     port_state->opaque[command] = opaque;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]