File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -213,7 +213,10 @@ func handleStandardSetup(setup usb.Setup) bool {
213213 if setup .WValueL == 1 { // DEVICEREMOTEWAKEUP
214214 isRemoteWakeUpEnabled = false
215215 } else if setup .WValueL == 0 { // ENDPOINTHALT
216- if usbStallHandler [setup .WIndex & 0x7F ] != nil {
216+ if setup .WIndex < usb .NumberOfEndpoints && usbStallHandler [setup .WIndex & 0x7F ] != nil {
217+ // Host has requested to clear an endpoint stall. If the request is addressed to
218+ // an endpoint with a configured StallHandler, forward the message on.
219+ // The 0x7F mask is used to clear the direction bit from the endpoint number
217220 return usbStallHandler [setup .WIndex & 0x7F ](setup )
218221 }
219222 isEndpointHalt = false
@@ -225,7 +228,10 @@ func handleStandardSetup(setup usb.Setup) bool {
225228 if setup .WValueL == 1 { // DEVICEREMOTEWAKEUP
226229 isRemoteWakeUpEnabled = true
227230 } else if setup .WValueL == 0 { // ENDPOINTHALT
228- if usbStallHandler [setup .WIndex & 0x7F ] != nil {
231+ if setup .WIndex < usb .NumberOfEndpoints && usbStallHandler [setup .WIndex & 0x7F ] != nil {
232+ // Host has requested to stall an endpoint. If the request is addressed to
233+ // an endpoint with a configured StallHandler, forward the message on.
234+ // The 0x7F mask is used to clear the direction bit from the endpoint number
229235 return usbStallHandler [setup .WIndex & 0x7F ](setup )
230236 }
231237 isEndpointHalt = true
You can’t perform that action at this time.
0 commit comments