dcavalca / rpms / qemu

Forked from rpms/qemu 11 months ago
Clone

Blame 0015-Fix-parse-of-usb-device-description-with-multiple-co.patch

Justin M. Forbes 45e84a
From 9b81fbdbb0cc930aacec343c6ab37adfd60c9e76 Mon Sep 17 00:00:00 2001
Justin M. Forbes 45e84a
From: "Cao,Bing Bu" <mars@linux.vnet.ibm.com>
Justin M. Forbes 45e84a
Date: Tue, 13 Dec 2011 09:22:20 +0800
Justin M. Forbes 45e84a
Subject: [PATCH 15/25] Fix parse of usb device description with multiple
Justin M. Forbes 45e84a
 configurations
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
Changed From V1:
Justin M. Forbes 45e84a
Use DPRINTF instead of fprintf,because it is not an error.
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
When testing ipod on QEMU by He Jie Xu<xuhj@linux.vnet.ibm.com>,qemu made a assertion.
Justin M. Forbes 45e84a
We found that the ipod with 2 configurations,and the usb-linux did not parse the descriptor correctly.
Justin M. Forbes 45e84a
The descr_len returned is the total length of the all configurations,not one configuration.
Justin M. Forbes 45e84a
The older version will through the other configurations instead of skip,continue parsing the descriptor of interfaces/endpoints in other configurations,then went wrong.
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
This patch will put the configuration descriptor parse in loop outside and dispel the other configurations not requested.
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
Signed-off-by: Cao,Bing Bu <mars@linux.vnet.ibm.com>
Justin M. Forbes 45e84a
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Justin M. Forbes 45e84a
---
Justin M. Forbes 45e84a
 usb-linux.c |   19 +++++++++++--------
Justin M. Forbes 45e84a
 1 files changed, 11 insertions(+), 8 deletions(-)
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
diff --git a/usb-linux.c b/usb-linux.c
Justin M. Forbes 45e84a
index ab4c693..ed14bb1 100644
Justin M. Forbes 45e84a
--- a/usb-linux.c
Justin M. Forbes 45e84a
+++ b/usb-linux.c
Justin M. Forbes 45e84a
@@ -1141,15 +1141,18 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
Justin M. Forbes 45e84a
     length = s->descr_len - 18;
Justin M. Forbes 45e84a
     i = 0;
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
-    if (descriptors[i + 1] != USB_DT_CONFIG ||
Justin M. Forbes 45e84a
-        descriptors[i + 5] != s->configuration) {
Justin M. Forbes 45e84a
-        fprintf(stderr, "invalid descriptor data - configuration %d\n",
Justin M. Forbes 45e84a
-                s->configuration);
Justin M. Forbes 45e84a
-        return 1;
Justin M. Forbes 45e84a
-    }
Justin M. Forbes 45e84a
-    i += descriptors[i];
Justin M. Forbes 45e84a
-
Justin M. Forbes 45e84a
     while (i < length) {
Justin M. Forbes 45e84a
+        if (descriptors[i + 1] != USB_DT_CONFIG) {
Justin M. Forbes 45e84a
+            fprintf(stderr, "invalid descriptor data\n");
Justin M. Forbes 45e84a
+            return 1;
Justin M. Forbes 45e84a
+        } else if (descriptors[i + 5] != s->configuration) {
Justin M. Forbes 45e84a
+            DPRINTF("not requested configuration %d\n", s->configuration);
Justin M. Forbes 45e84a
+            i += (descriptors[i + 3] << 8) + descriptors[i + 2];
Justin M. Forbes 45e84a
+            continue;
Justin M. Forbes 45e84a
+        }
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
+        i += descriptors[i];
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
         if (descriptors[i + 1] != USB_DT_INTERFACE ||
Justin M. Forbes 45e84a
             (descriptors[i + 1] == USB_DT_INTERFACE &&
Justin M. Forbes 45e84a
              descriptors[i + 4] == 0)) {
Justin M. Forbes 45e84a
-- 
Justin M. Forbes 45e84a
1.7.7.5
Justin M. Forbes 45e84a