From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URTCq-0003OL-50 for qemu-devel@nongnu.org; Sun, 14 Apr 2013 16:07:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URTCp-00069R-44 for qemu-devel@nongnu.org; Sun, 14 Apr 2013 16:07:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URTCo-000694-T6 for qemu-devel@nongnu.org; Sun, 14 Apr 2013 16:07:19 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3EK7HG4023692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 14 Apr 2013 16:07:17 -0400 From: Cole Robinson Date: Sun, 14 Apr 2013 16:06:59 -0400 Message-Id: <681f15c0b6ac898724d68227f34977b106c7fa59.1365969853.git.crobinso@redhat.com> Subject: [Qemu-devel] [PATCH] ccid: Fix crash when backend isn't specified List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alevy@redhat.com, kraxel@redhat.com, Cole Robinson Reproducer: ./x86_64-softmmu/qemu-system-x86_64 -device usb-ccid,id=ccid0 -usb -device ccid-card-emulated -monitor stdio Signed-off-by: Cole Robinson --- hw/usb/ccid-card-emulated.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index 29dcd7a..65e1432 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -500,9 +500,15 @@ static int emulated_initfn(CCIDCardState *base) if (init_pipe_signaling(card) < 0) { return -1; } - card->backend = parse_enumeration(card->backend_str, backend_enum_table, 0); + + card->backend = 0; + if (card->backend_str) { + card->backend = parse_enumeration(card->backend_str, + backend_enum_table, 0); + } + if (card->backend == 0) { - printf("unknown backend, must be one of:\n"); + printf("backend must be one of:\n"); for (ptable = backend_enum_table; ptable->name != NULL; ++ptable) { printf("%s\n", ptable->name); } -- 1.8.1.4