Skip to content

Commit

Permalink
ccid: Fix crash when backend isn't specified
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
crobinso authored and Alon Levy committed Apr 26, 2013
1 parent 909eedb commit ae12e3a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hw/usb/ccid-card-emulated.c
Expand Up @@ -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);
}
Expand Down

0 comments on commit ae12e3a

Please sign in to comment.