Skip to content

Commit 2548288

Browse files
AlanSterngregkh
authored andcommitted
USB: Fix: Don't skip endpoint descriptors with maxpacket=0
It turns out that even though endpoints with a maxpacket length of 0 aren't useful for data transfer, the descriptors do serve other purposes. In particular, skipping them will also skip over other class-specific descriptors for classes such as UVC. This unexpected side effect has caused some UVC cameras to stop working. In addition, the USB spec requires that when isochronous endpoint descriptors are present in an interface's altsetting 0 (which is true on some devices), the maxpacket size _must_ be set to 0. Warning about such things seems like a bad idea. This patch updates an earlier commit which would log a warning and skip these endpoint descriptors. Now we only log a warning, and we don't even do that for isochronous endpoints in altsetting 0. We don't need to worry about preventing endpoints with maxpacket = 0 from ever being used for data transfers; usb_submit_urb() already checks for this. Reported-and-tested-by: Roger Whittaker <[email protected]> Fixes: d482c7b ("USB: Skip endpoints with 0 maxpacket length") Signed-off-by: Alan Stern <[email protected]> CC: Laurent Pinchart <[email protected]> Link: https://marc.info/?l=linux-usb&m=157790377329882&w=2 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c215e48 commit 2548288

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/usb/core/config.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
392392
endpoint->desc.wMaxPacketSize = cpu_to_le16(8);
393393
}
394394

395-
/* Validate the wMaxPacketSize field */
395+
/*
396+
* Validate the wMaxPacketSize field.
397+
* Some devices have isochronous endpoints in altsetting 0;
398+
* the USB-2 spec requires such endpoints to have wMaxPacketSize = 0
399+
* (see the end of section 5.6.3), so don't warn about them.
400+
*/
396401
maxp = usb_endpoint_maxp(&endpoint->desc);
397-
if (maxp == 0) {
398-
dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has wMaxPacketSize 0, skipping\n",
402+
if (maxp == 0 && !(usb_endpoint_xfer_isoc(d) && asnum == 0)) {
403+
dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid wMaxPacketSize 0\n",
399404
cfgno, inum, asnum, d->bEndpointAddress);
400-
goto skip_to_next_endpoint_or_interface_descriptor;
401405
}
402406

403407
/* Find the highest legal maxpacket size for this endpoint */

0 commit comments

Comments
 (0)