usb: Handle audio extension endpoint descriptor in usb_parse_config() 66/191966/1 submit/tizen/20181031.053034 submit/tizen/20181101.042526
authorBin Meng <bmeng.cn@gmail.com>
Mon, 18 Sep 2017 13:40:40 +0000 (06:40 -0700)
committerJaechul Lee <jcsing.lee@samsung.com>
Fri, 26 Oct 2018 05:59:58 +0000 (14:59 +0900)
Normal endpoint descriptor size is 7, but for audio extension it is
9. Handle that correctly when parsing endpoint descriptor.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
[jcsing.lee: cherry-pick from mainline to fix booting hanging]
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
Change-Id: Icf90864b9649686dd17132af3493a5bab6c7f4e3

common/usb.c

index 15e1e4c..aeb40ab 100644 (file)
@@ -440,12 +440,13 @@ static int usb_parse_config(struct usb_device *dev,
                        }
                        break;
                case USB_DT_ENDPOINT:
-                       if (head->bLength != USB_DT_ENDPOINT_SIZE) {
+                       if (head->bLength != USB_DT_ENDPOINT_SIZE &&
+                           head->bLength != USB_DT_ENDPOINT_AUDIO_SIZE) {
                                printf("ERROR: Invalid USB EP length (%d)\n",
                                        head->bLength);
                                break;
                        }
-                       if (index + USB_DT_ENDPOINT_SIZE >
+                       if (index + head->bLength >
                            dev->config.desc.wTotalLength) {
                                puts("USB EP descriptor overflowed buffer!\n");
                                break;