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 <crobinso@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
This commit is contained in:
Cole Robinson 2013-04-14 16:06:59 -04:00 committed by Alon Levy
parent 909eedb74f
commit ae12e3a643

View 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);
}