summaryrefslogtreecommitdiffstats
path: root/hw/i386/vmport.c
diff options
context:
space:
mode:
authorLiran Alon2020-03-12 17:54:31 +0100
committerPaolo Bonzini2020-06-10 18:09:54 +0200
commit23accdf162dcccb9fec9585a64ad01a87b13da5c (patch)
tree785921c36fa0e974145b52279f752e1e1b6648f8 /hw/i386/vmport.c
parenthw/i386/vmport: Add support for CMD_GETHZ (diff)
downloadqemu-23accdf162dcccb9fec9585a64ad01a87b13da5c.tar.gz
qemu-23accdf162dcccb9fec9585a64ad01a87b13da5c.tar.xz
qemu-23accdf162dcccb9fec9585a64ad01a87b13da5c.zip
hw/i386/vmport: Assert vmport initialized before registering commands
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 <nikita.leshchenko@oracle.com> Signed-off-by: Liran Alon <liran.alon@oracle.com> Message-Id: <20200312165431.82118-17-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/i386/vmport.c')
-rw-r--r--hw/i386/vmport.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c
index 309cfd105b..79ef25d223 100644
--- a/hw/i386/vmport.c
+++ b/hw/i386/vmport.c
@@ -81,6 +81,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;