diff mbox

ccid: Fix crash when backend isn't specified

Message ID 681f15c0b6ac898724d68227f34977b106c7fa59.1365969853.git.crobinso@redhat.com
State New
Headers show

Commit Message

Cole Robinson April 14, 2013, 8:06 p.m. UTC
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>
---
 hw/usb/ccid-card-emulated.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Alon Levy April 15, 2013, 8:03 a.m. UTC | #1
On Sun, 2013-04-14 at 16:06 -0400, Cole Robinson wrote:
> Reproducer:
> 
> ./x86_64-softmmu/qemu-system-x86_64 -device usb-ccid,id=ccid0 -usb -device ccid-card-emulated -monitor stdio
> 

ACK, thanks.

Marc-Andre, could you review the fixed patches I sent previously, and
then I can put this on top and send a pull request?

http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg04927.html

> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
>  hw/usb/ccid-card-emulated.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
> index 29dcd7a..65e1432 100644
> --- a/hw/usb/ccid-card-emulated.c
> +++ b/hw/usb/ccid-card-emulated.c
> @@ -500,9 +500,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);
>          }
> -- 
> 1.8.1.4
> 
>
diff mbox

Patch

diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 29dcd7a..65e1432 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -500,9 +500,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);
         }