ccid: Fix crash when backend isn't specified
authorCole Robinson <crobinso@redhat.com>
Sun, 14 Apr 2013 20:06:59 +0000 (16:06 -0400)
committerAlon Levy <alevy@redhat.com>
Fri, 26 Apr 2013 23:38:33 +0000 (02:38 +0300)
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>
hw/usb/ccid-card-emulated.c

index 094284d664ce1f951488efab19d1a1bed20d7148..deb6d4703be013e78fb9eb379e7185b824092391 100644 (file)
@@ -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);
         }