summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2013-04-14 16:06:59 -0400
committerAlon Levy <alevy@redhat.com>2013-04-27 02:38:33 +0300
commitae12e3a643c66575c77211e1226ada041e56b889 (patch)
tree7cc0aabecf2ef895ea2d1f531ad43c67555da75d
parent909eedb74f88d1d6d9e6bbdc34875772e7a8a5ab (diff)
ccid: Fix crash when backend isn't specifiedlibcacard_ccid.2
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 <crobinso@redhat.com> Reviewed-by: Alon Levy <alevy@redhat.com>
-rw-r--r--hw/usb/ccid-card-emulated.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 094284d66..deb6d4703 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);
}