From patchwork Wed Mar 4 09:03:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 446153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7625114016B for ; Wed, 4 Mar 2015 20:04:46 +1100 (AEDT) Received: from localhost ([::1]:42765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT5ES-0004fx-AW for incoming@patchwork.ozlabs.org; Wed, 04 Mar 2015 04:04:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT5Du-0004Y9-AN for qemu-devel@nongnu.org; Wed, 04 Mar 2015 04:04:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YT5Dr-0003jV-Jv for qemu-devel@nongnu.org; Wed, 04 Mar 2015 04:04:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56957) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT5Dr-0003iL-D0 for qemu-devel@nongnu.org; Wed, 04 Mar 2015 04:04:07 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t24945bY017021 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 4 Mar 2015 04:04:06 -0500 Received: from localhost (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t249439R008833; Wed, 4 Mar 2015 04:04:04 -0500 From: Amit Shah To: qemu list Date: Wed, 4 Mar 2015 14:33:56 +0530 Message-Id: <36afc0db03021aa7259dc76107e8f5bb4ae61e10.1425459836.git.amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amit Shah , Markus Armbruster Subject: [Qemu-devel] [PATCH 1/1] virtio-serial: fix segfault on NULL port names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. https://bugzilla.redhat.com/show_bug.cgi?id=1192775 Reported-by: vivian zhang Signed-off-by: Amit Shah Reviewed-by: Markus Armbruster --- 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 47fbb34..acd1173 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; } }