summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-09-17 10:30:17 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-09-20 17:38:56 -0400
commit99f333c64f13c3f9a62b9f5e184ae87f053bf65a (patch)
treed4c31cd346cc13b173965d56df8041613baa9ab2
parent483563a1b2cd5d463557580498d75a693dd79077 (diff)
downloadrockbox-99f333c64f13c3f9a62b9f5e184ae87f053bf65a.tar.gz
rockbox-99f333c64f13c3f9a62b9f5e184ae87f053bf65a.tar.bz2
rockbox-99f333c64f13c3f9a62b9f5e184ae87f053bf65a.zip
usb_hid: fix accidental fallthrough
Successful SET REPORT requests would spuriously fail because of the fall through to GET REPORT. Change-Id: I8e7d1a1120afc6975d07d47b11c12c9e9ca51dd2
-rw-r--r--firmware/usbstack/usb_hid.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/firmware/usbstack/usb_hid.c b/firmware/usbstack/usb_hid.c
index 5885b60e32..885ae4c24a 100644
--- a/firmware/usbstack/usb_hid.c
+++ b/firmware/usbstack/usb_hid.c
@@ -785,27 +785,39 @@ 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_REPORT) ? "set report" :
((req->bRequest == USB_HID_GET_REPORT) ? "get report" : "")));
+
+ int rc;
switch (req->bRequest)
{
case USB_HID_SET_REPORT:
- if (usb_hid_set_report(req))
- break;
+ rc = usb_hid_set_report(req);
+ break;
case USB_HID_GET_REPORT:
- if (usb_hid_get_report(req, &dest))
- break;
+ rc = usb_hid_get_report(req, &dest);
+ break;
case USB_HID_SET_IDLE:
- if (dest != orig_dest)
- {
- usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */
- usb_drv_send(EP_CONTROL, orig_dest, dest - orig_dest);
- }
- else
- {
- usb_drv_send(EP_CONTROL, NULL, 0); /* ack */
- }
- return true;
+ rc = 0;
+ break;
+ default:
+ /* all other requests are errors */
+ rc = -1;
+ break;
}
- break;
+
+ if(rc != 0)
+ break;
+
+ if (dest != orig_dest)
+ {
+ usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */
+ usb_drv_send(EP_CONTROL, orig_dest, dest - orig_dest);
+ }
+ else
+ {
+ usb_drv_send(EP_CONTROL, NULL, 0); /* ack */
+ }
+
+ return true;
}
case USB_TYPE_VENDOR: