CVSROOT:        /cvs
Module name:    src
Changes by:     e...@cvs.openbsd.org    2021/01/29 04:44:06

Modified files:
        sys/dev/usb    : usbdi.c 

Log message:
Don't rely on USB interfaces being at compliant indices.

When obtaining an interface handle, we currently rely on the device being
properly USB compliant, and thus the interface being at the correct index in
the interfaces array.

However, some devices present their indices incorrectly. For example, the
following audio device exposes interfaces 0, 1 and 3, in that order (skipping
interface 2 entirely):

uaudio2 at uhub4 port 4 configuration 1 interface 3 "E+ Corp. DAC Audio" rev 
1.10/0.01 addr 2
uaudio2: class v1, full-speed, async, channels: 2 play, 0 rec, 3 ctls

This means that that the audio stream interface (number 3) is not found at the
expected index of 2, and this causes looking up the handle to fail.

This change makes usbd_device2interface_handle() search for the right
interface, instead of assuming it will be at the right index. Although this is
a little slower, note that this routine not very frequently called and there
are typically not hundreds of interfaces on a typical USB device.

This fixes the above E+ Corp device, and one other uaudio device reported
broken by a user.

With input from, tested by, and OK ratchov@, mglocker@ and kettenis@.

Many thanks!

Reply via email to