]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio-serial: avoid crash when port has no name
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Wed, 5 Nov 2014 14:43:14 +0000 (15:43 +0100)
committerAmit Shah <amit.shah@redhat.com>
Fri, 7 Nov 2014 04:57:11 +0000 (10:27 +0530)
It seems "name" is not mandatory, and the following command line (based
on one generated by current libvirt) will crash qemu at start:

qemu-system-x86_64 \
    -device virtio-serial-pci \
    -device virtserialport,name=foo \
    -device virtconsole

Program received signal SIGSEGV, Segmentation fault.
__strcmp_ssse3 () at ../sysdeps/x86_64/strcmp.S:210
210        movlpd    (%rsi), %xmm2
Missing separate debuginfos, use: debuginfo-install
python-libs-2.7.5-13.fc20.x86_64
(gdb) bt
 #0  __strcmp_ssse3 () at ../sysdeps/x86_64/strcmp.S:210
 #1  0x000055555566bdc6 in find_port_by_name (name=0x0) at /home/elmarco/src/qemu/hw/char/virtio-serial-bus.c:67

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Reviewed-by: Amos Kong <akong@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
hw/char/virtio-serial-bus.c

index c6870f19e1702ea18f9076b17b7e508c5c403ac7..a7b1b68984e8cc8be8f908548951d0e3f5a7bb62 100644 (file)
@@ -871,7 +871,7 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    if (find_port_by_name(port->name)) {
+    if (port->name != NULL && find_port_by_name(port->name)) {
         error_setg(errp, "virtio-serial-bus: A port already exists by name %s",
                    port->name);
         return;