Hi, Sending this patch to tech@ in case people have usb audio devices to test it.
When connecting yamaha ur12 usb audio interface I was getting USBD_INVAL because of the aclen check. netbsd previously removed the check for aclen here: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/usb/uaudio.c.diff?r1=1.119&r2=1.120&f=h&f=u So this patch is a copy, without the Roland SD-90 stuff. I originally applied this to uaudio.c r1.116 and it allowed ur12 device to progress further. usb device attach then failed later related to unexpected format type or other sample encoding details. That would need to be addressed later in uaudio_process_as(). - Michael Index: uaudio.c =================================================================== RCS file: /cvs/src/sys/dev/usb/uaudio.c,v retrieving revision 1.122 diff -u -p -u -r1.122 uaudio.c --- uaudio.c 3 Jan 2017 06:45:58 -0000 1.122 +++ uaudio.c 3 Jan 2017 08:14:27 -0000 @@ -1788,7 +1788,7 @@ uaudio_identify_ac(struct uaudio_softc * const struct usb_audio_output_terminal *pot; struct terminal_list *tml; const char *buf, *ibuf, *ibufend; - int size, offs, aclen, ndps, i, j; + int size, offs, ndps, i, j; size = UGETW(cdesc->wTotalLength); buf = (char *)cdesc; @@ -1807,26 +1807,23 @@ uaudio_identify_ac(struct uaudio_softc * /* A class-specific AC interface header should follow. */ ibuf = buf + offs; + ibufend = buf + size; acdp = (const struct usb_audio_control_descriptor *)ibuf; if (acdp->bDescriptorType != UDESC_CS_INTERFACE || acdp->bDescriptorSubtype != UDESCSUB_AC_HEADER) return (USBD_INVAL); - aclen = UGETW(acdp->wTotalLength); - if (offs + aclen > size) - return (USBD_INVAL); if (!(sc->sc_quirks & UAUDIO_FLAG_BAD_ADC) && UGETW(acdp->bcdADC) != UAUDIO_VERSION) return (USBD_INVAL); sc->sc_audio_rev = UGETW(acdp->bcdADC); - DPRINTFN(2,("%s: found AC header, vers=%03x, len=%d\n", - __func__, sc->sc_audio_rev, aclen)); + DPRINTFN(2,("%s: found AC header, vers=%03x\n", + __func__, sc->sc_audio_rev)); sc->sc_nullalt = -1; /* Scan through all the AC specific descriptors */ - ibufend = ibuf + aclen; dp = (const usb_descriptor_t *)ibuf; ndps = 0; iot = malloc(256 * sizeof(struct io_terminal), @@ -1844,11 +1841,8 @@ uaudio_identify_ac(struct uaudio_softc * free(iot, M_TEMP, 0); return (USBD_INVAL); } - if (dp->bDescriptorType != UDESC_CS_INTERFACE) { - printf("%s: skip desc type=0x%02x\n", - __func__, dp->bDescriptorType); - continue; - } + if (dp->bDescriptorType != UDESC_CS_INTERFACE) + break; i = ((const struct usb_audio_input_terminal *)dp)->bTerminalId; iot[i].d.desc = dp; if (i > ndps)