From ae12e3a643c66575c77211e1226ada041e56b889 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 14 Apr 2013 16:06:59 -0400 Subject: ccid: Fix crash when backend isn't specified 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 Reviewed-by: Alon Levy --- hw/usb/ccid-card-emulated.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'hw/usb/ccid-card-emulated.c') diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index 094284d664..deb6d4703b 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -503,9 +503,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); } -- cgit v1.2.3