1
0
Fork 0
forked from len0rd/rockbox

usb_hid: fix accidental fallthrough

Successful SET REPORT requests would spuriously fail because of the
fall through to GET REPORT.

Change-Id: I8e7d1a1120afc6975d07d47b11c12c9e9ca51dd2
This commit is contained in:
Aidan MacDonald 2021-09-17 10:30:17 +01:00
parent 483563a1b2
commit 99f333c64f

View file

@ -785,15 +785,28 @@ bool usb_hid_control_request(struct usb_ctrlrequest *req, unsigned char *dest)
(req->bRequest == USB_HID_SET_IDLE) ? "set idle" : (req->bRequest == USB_HID_SET_IDLE) ? "set idle" :
((req->bRequest == USB_HID_SET_REPORT) ? "set report" : ((req->bRequest == USB_HID_SET_REPORT) ? "set report" :
((req->bRequest == USB_HID_GET_REPORT) ? "get report" : ""))); ((req->bRequest == USB_HID_GET_REPORT) ? "get report" : "")));
int rc;
switch (req->bRequest) switch (req->bRequest)
{ {
case USB_HID_SET_REPORT: case USB_HID_SET_REPORT:
if (usb_hid_set_report(req)) rc = usb_hid_set_report(req);
break; break;
case USB_HID_GET_REPORT: case USB_HID_GET_REPORT:
if (usb_hid_get_report(req, &dest)) rc = usb_hid_get_report(req, &dest);
break; break;
case USB_HID_SET_IDLE: case USB_HID_SET_IDLE:
rc = 0;
break;
default:
/* all other requests are errors */
rc = -1;
break;
}
if(rc != 0)
break;
if (dest != orig_dest) if (dest != orig_dest)
{ {
usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */ usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */
@ -803,10 +816,9 @@ bool usb_hid_control_request(struct usb_ctrlrequest *req, unsigned char *dest)
{ {
usb_drv_send(EP_CONTROL, NULL, 0); /* ack */ usb_drv_send(EP_CONTROL, NULL, 0); /* ack */
} }
return true; return true;
} }
break;
}
case USB_TYPE_VENDOR: case USB_TYPE_VENDOR:
logf("hid: unsup. ven. req"); logf("hid: unsup. ven. req");