]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 22 Jan 2021 09:25:45 +0000 (10:25 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 27 Jan 2021 08:39:40 +0000 (09:39 +0100)
commit69977ff10560a80bcf5bf93f1a3f819a2d1623ca
tree717d2142ca832c2497623a0dd010a9255bdc6565
parent225c56837894eeb4441053127254423800b39282
qemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()

If QEMU driver fails to initialize for whatever reason (it can be
as trivial as a typo on qemu.conf), the control jumps to error
label in qemuStateInitialize() where qemuStateCleanup() is called
which frees the driver. But the daemon then asks drivers to
prepare for shutdown, which in case of QEMU driver is implemented
in qemuStateShutdownPrepare(). In here, the driver is
dereferenced but since it was freed earlier, the pointer is NULL
which leads to instant crash.

Solution is simple - just check if qemu_driver is not NULL. But
doing so only in qemuStateShutdownPrepare() would push the
problem down to virStateShutdownWait(), well
qemuStateShutdownWait(). Therefore, duplicate the trick there
too.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1895359#c14
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_driver.c