aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2012-06-12 14:23:52 -0400
committerLuis Henriques <luis.henriques@canonical.com>2012-07-03 11:29:12 -0400
commitd14d8cabe302982d48ad9f8afc3f3ecc68666a50 (patch)
treed161f7966da272ed0bc54e511a9eaed843d9cd95 /drivers/usb/core
parentf5b3ae26271f6a636daab7d2bc6a43155bdc8b1c (diff)
USB: fix gathering of interface associations
BugLink: http://bugs.launchpad.net/bugs/1016720 commit b3a3dd074f7053ef824ad077e5331b52220ceba1 upstream. TEAC's UD-H01 (and probably other devices) have a gap in the interface number allocation of their descriptors: Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 220 bNumInterfaces 3 [...] Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 [...] Interface Association: bLength 8 bDescriptorType 11 bFirstInterface 2 bInterfaceCount 2 bFunctionClass 1 Audio bFunctionSubClass 0 bFunctionProtocol 32 iFunction 4 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 2 bAlternateSetting 0 [...] Once a configuration is selected, usb_set_configuration() walks the known interfaces of a given configuration and calls find_iad() on each of them to set the interface association pointer the interface is included in. The problem here is that the loop variable is taken for the interface number in the comparison logic that gathers the association. Which is fine as long as the descriptors are sane. In the case above, however, the logic gets out of sync and the interface association fields of all interfaces beyond the interface number gap are wrong. Fix this by passing the interface's bInterfaceNumber to find_iad() instead. Signed-off-by: Daniel Mack <zonque@gmail.com> Reported-by: bEN <ml_all@circa.be> Reported-by: Ivan Perrone <ivanperrone@hotmail.com> Tested-by: ivan perrone <ivanperrone@hotmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/message.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 1eebd45b813..806060ca932 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1803,7 +1803,6 @@ free_interfaces:
1803 intfc = cp->intf_cache[i]; 1803 intfc = cp->intf_cache[i];
1804 intf->altsetting = intfc->altsetting; 1804 intf->altsetting = intfc->altsetting;
1805 intf->num_altsetting = intfc->num_altsetting; 1805 intf->num_altsetting = intfc->num_altsetting;
1806 intf->intf_assoc = find_iad(dev, cp, i);
1807 kref_get(&intfc->ref); 1806 kref_get(&intfc->ref);
1808 1807
1809 alt = usb_altnum_to_altsetting(intf, 0); 1808 alt = usb_altnum_to_altsetting(intf, 0);
@@ -1816,6 +1815,8 @@ free_interfaces:
1816 if (!alt) 1815 if (!alt)
1817 alt = &intf->altsetting[0]; 1816 alt = &intf->altsetting[0];
1818 1817
1818 intf->intf_assoc =
1819 find_iad(dev, cp, alt->desc.bInterfaceNumber);
1819 intf->cur_altsetting = alt; 1820 intf->cur_altsetting = alt;
1820 usb_enable_interface(dev, intf, true); 1821 usb_enable_interface(dev, intf, true);
1821 intf->dev.parent = &dev->dev; 1822 intf->dev.parent = &dev->dev;