From: Michael Ellerman Date: Sun, 13 Nov 2011 17:18:59 +0000 (+0000) Subject: pseries: Check we have a chardev in spapr_vty_init() X-Git-Tag: qemu-xen-4.2.0~114^2~6^2~3 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=57285302af51a8bae334c03e1f8243e935373953;p=qemu-upstream-4.2-testing.git pseries: Check we have a chardev in spapr_vty_init() 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 Signed-off-by: Alexander Graf --- diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c index a9d4b035e..f4f3ee32a 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);