Skip to content

Commit

Permalink
virtio-serial: avoid crash when port has no name
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Amos Kong <[email protected]>
Signed-off-by: Amit Shah <[email protected]>
  • Loading branch information
elmarco authored and amit3s committed Nov 7, 2014
1 parent 6e76d12 commit 7eb7311
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/char/virtio-serial-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7eb7311

Please sign in to comment.