From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmL7e-0001Bt-Dc for qemu-devel@nongnu.org; Thu, 06 Nov 2014 06:21:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XmL7X-00039Y-Dd for qemu-devel@nongnu.org; Thu, 06 Nov 2014 06:21:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmL7X-00039R-4L for qemu-devel@nongnu.org; Thu, 06 Nov 2014 06:20:55 -0500 From: Amit Shah Date: Thu, 6 Nov 2014 16:50:38 +0530 Message-Id: <745d32d12f10badaafd26088c616025ebfe223fe.1415272750.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 2/2] virtio-serial: avoid crash when port has no name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Amit Shah , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 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=3Dfoo \ -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=3D0x0) at /home/elmarc= o/src/qemu/hw/char/virtio-serial-bus.c:67 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Amos Kong Signed-off-by: Amit Shah --- 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 bea7a17..c191283 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -902,7 +902,7 @@ static void virtser_port_device_realize(DeviceState *= dev, Error **errp) return; } =20 - if (find_port_by_name(port->name)) { + if (port->name !=3D NULL && find_port_by_name(port->name)) { error_setg(errp, "virtio-serial-bus: A port already exists by na= me %s", port->name); return; --=20 1.9.3