]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_hotplug: fix crash in hot(un)plugging chardev devices
authorPavel Hrdina <phrdina@redhat.com>
Tue, 18 Oct 2016 06:59:14 +0000 (08:59 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 18 Oct 2016 11:34:07 +0000 (13:34 +0200)
We need to make sure that the chardev is TCP.  Without this check we
may access different part of union and corrupt pointers.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_hotplug.c

index 14af4e11c5d983c2e10508eedd7f9b81ca6dbfe2..c2ba9357c080446cf24b784ce4c276d2e90beb7c 100644 (file)
@@ -1729,7 +1729,8 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
     if (qemuDomainChrPreInsert(vmdef, chr) < 0)
         goto cleanup;
 
-    if (cfg->chardevTLS) {
+    if (dev->type == VIR_DOMAIN_CHR_TYPE_TCP &&
+        cfg->chardevTLS) {
         if (qemuBuildTLSx509BackendProps(cfg->chardevTLSx509certdir,
                                          dev->data.tcp.listen,
                                          cfg->chardevTLSx509verify,
@@ -4398,7 +4399,8 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
 
     sa_assert(tmpChr->info.alias);
 
-    if (cfg->chardevTLS &&
+    if (tmpChr->source.type == VIR_DOMAIN_CHR_TYPE_TCP &&
+        cfg->chardevTLS &&
         !(objAlias = qemuAliasTLSObjFromChardevAlias(tmpChr->info.alias)))
         goto cleanup;