From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm1oB-0006S5-AJ for qemu-devel@nongnu.org; Wed, 05 Nov 2014 09:43:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm1nx-0002YN-1o for qemu-devel@nongnu.org; Wed, 05 Nov 2014 09:43:39 -0500 Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:42909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm1nw-0002Xl-My for qemu-devel@nongnu.org; Wed, 05 Nov 2014 09:43:24 -0500 Received: by mail-lb0-f171.google.com with SMTP id b6so779893lbj.16 for ; Wed, 05 Nov 2014 06:43:22 -0800 (PST) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 5 Nov 2014 15:43:14 +0100 Message-Id: <1415198594-32581-1-git-send-email-marcandre.lureau@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCHv2] virtio-serial: avoid crash when port has no name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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 --- 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.9.3