From c569b05d16b74985cb32f66e727444f2a979c3ee Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Mon, 10 Nov 2014 16:49:35 +0100 Subject: [PATCH 5/5] virtio-serial: avoid crash when port has no name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-id: <182de83f26aad5ad9264bce69c761710694acdeb.1415637309.git.amit.shah@redhat.com> Patchwork-id: 62261 O-Subject: [RHEL-7.1 qemu-kvm-rhev PATCH 1/1] virtio-serial: avoid crash when port has no name Bugzilla: 1151947 RH-Acked-by: Paolo Bonzini RH-Acked-by: Luiz Capitulino RH-Acked-by: Amos Kong RH-Acked-by: Gerd Hoffmann From: Marc-André Lureau 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 Reviewed-by: Amos Kong Signed-off-by: Amit Shah (cherry picked from commit 7eb7311427a6e2a9e080c1224f86a897f077282f) Signed-off-by: Amit Shah Signed-off-by: Miroslav Rezanina --- hw/char/virtio-serial-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 3931085..f16452e 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -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; -- 1.8.3.1