Skip to content

Commit b3e40fc

Browse files
oneukumgregkh
authored andcommitted
USB: usb_parse_endpoint: ignore reserved bits
Reading bEndpointAddress the spec tells is that: b7 is direction, which must be ignored b6:4 are reserved which are to be set to zero b3:0 are the endpoint address In order to be backwards compatible with possible future versions of USB we have to be ready with devices using those bits. That means that we also have to ignore them like we do with the direction bit. In consequence the only illegal address you can encoding in four bits is endpoint zero, for which no descriptor must exist. Hence the check for exceeding the upper limit on endpoint addresses is removed. Signed-off-by: Oliver Neukum <[email protected]> Reviewed-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 080e73c commit b3e40fc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/usb/core/config.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,11 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
279279
goto skip_to_next_endpoint_or_interface_descriptor;
280280
}
281281

282-
i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK;
283-
if (i >= 16 || i == 0) {
282+
i = d->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
283+
if (i == 0) {
284284
dev_notice(ddev, "config %d interface %d altsetting %d has an "
285-
"invalid endpoint with address 0x%X, skipping\n",
286-
cfgno, inum, asnum, d->bEndpointAddress);
285+
"invalid descriptor for endpoint zero, skipping\n",
286+
cfgno, inum, asnum);
287287
goto skip_to_next_endpoint_or_interface_descriptor;
288288
}
289289

0 commit comments

Comments
 (0)