From: Amit Shah Date: Wed, 4 Mar 2015 08:59:52 +0000 (+0530) Subject: virtio-serial: fix segfault on NULL port names X-Git-Tag: v2.3.0-rc0~25^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b18a755c4266a340a25ab4118525bd57c3dfc3fa;p=thirdparty%2Fqemu.git virtio-serial: fix segfault on NULL port names Commit d0a0bfe6729ef6044d76ea49fafa07e29fa598bd added checks for port names, but didn't add a check to ensure port->name is non-NULL. This results in a SIGSEGV when adding a port when one of the previously-added ports didn't have the 'name' property set. https://bugzilla.redhat.com/show_bug.cgi?id=1192775 Reported-by: vivian zhang Reviewed-by: Markus Armbruster Signed-off-by: Amit Shah --- diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 9a029d2130a..c86814f0596 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -64,7 +64,7 @@ static VirtIOSerialPort *find_port_by_name(char *name) VirtIOSerialPort *port; QTAILQ_FOREACH(port, &vser->ports, next) { - if (!strcmp(port->name, name)) { + if (port->name && !strcmp(port->name, name)) { return port; } }