usb: usb_parse_endpoint ignore reserved bits
PATCH v3 1/1 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.
---
v2: Improved commit log
v3: Symbolic mask and improved error message
drivers/usb/core/config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/core/config.c +4 -4
@@ -279,11 +279,11 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, goto skip_to_next_endpoint_or_interface_descriptor; } - i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK ; -if (i >=16 || i ==0 ) { + i = d->bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ; +if (i ==0 ) {dev_notice (ddev,"config %d interface %d altsetting %d has an " -"invalid endpoint with address 0x%X, skipping\n" , - cfgno, inum, asnum, d->bEndpointAddress); +"invalid descriptor for endpoint zero, skipping\n" , + cfgno, inum, asnum); goto skip_to_next_endpoint_or_interface_descriptor; }
Signature · 1 line
2.44.0
Quoted 17 lines · Oliver Neukum
Reading bEndpointAddress the spec tells is
thatb7 is direction, which must be ignored
b6:4 are reserved which are to be set to zero b3:0 are the endpoint addressIn 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.
Quoted 2 lines
Signed-off-by Oliver Neukum <[email protected]>---
Quoted 28 lines
v2: Improved commit log
v3: Symbolic mask and improved error messagedrivers/usb/core/config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/usb/core/config.c +4
-4@@ -279,11 +279,11 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, goto skip_to_next_endpoint_or_interface_descriptor; } - i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK ; -if (i >=16 || i ==0 ) { + i = d->bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ; +if (i ==0 ) {dev_notice (ddev,"config %d interface %d altsetting %d has an " -"invalid endpoint with address 0x%X, skipping\n" , - cfgno, inum, asnum, d->bEndpointAddress); +"invalid descriptor for endpoint zero, skipping\n" , + cfgno, inum, asnum); goto skip_to_next_endpoint_or_interface_descriptor; }Signature · 1 line
2.44.0