From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPn4a-0002nr-Jn for qemu-devel@nongnu.org; Sun, 13 Nov 2011 22:19:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPn4X-0008OX-BS for qemu-devel@nongnu.org; Sun, 13 Nov 2011 22:19:04 -0500 From: David Gibson Date: Mon, 14 Nov 2011 14:18:59 +1100 Message-Id: <1321240741-23055-4-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1321240741-23055-1-git-send-email-david@gibson.dropbear.id.au> References: <1321240741-23055-1-git-send-email-david@gibson.dropbear.id.au> Subject: [Qemu-devel] [PATCH 3/5] pseries: Check we have a chardev in spapr_vty_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: agraf@suse.de Cc: michael@ellerman.id.au, qemu-ppc@nongnu.org, qemu-devel@nongnu.org From: Michael Ellerman If qemu is run like: qemu-system-ppc64 -nodefaults -device spapr-vty We end up in spapr_vty_init() with dev->chardev == NULL. Currently that leads to a segfault because we unconditionally call qemu_chr_add_handlers(). Although we could make that call conditional, I think a spapr-vty without a chardev is basically useless so fail the init. This is similar to what the serial code does for example. Signed-off-by: Michael Ellerman Signed-off-by: David Gibson --- hw/spapr_vty.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c index a9d4b03..f4f3ee3 100644 --- a/hw/spapr_vty.c +++ b/hw/spapr_vty.c @@ -58,6 +58,11 @@ static int spapr_vty_init(VIOsPAPRDevice *sdev) { VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)sdev; + if (!dev->chardev) { + fprintf(stderr, "spapr-vty: Can't create vty without a chardev!\n"); + exit(1); + } + qemu_chr_add_handlers(dev->chardev, vty_can_receive, vty_receive, NULL, dev); -- 1.7.7.1