[PATCH 2/9] HID: core: Fix GET_REPORT input processing for unnumbered reports
From: Dmitry Torokhov
Date: Mon Oct 12 2026 - 23:48:04 EST
When emulating report retrieval requests in the HID core, low-level
transport drivers store a dummy report ID of 0 at the start of the
buffer for unnumbered reports, with the actual report payload placed
after the initial byte.
Passing the raw transfer buffer and total returned length directly to
the input layer causes unnumbered reports to be processed with an
extraneous leading byte and an incorrect payload length. Offset the
buffer past the leading byte and deduct the dummy report ID from the
length when forwarding unnumbered reports to the input layer.
Fixes: 0d0777ccaa2d ("HID: core: ensure __hid_request reserves the report ID as the first byte")
Assisted-by: LLM
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hid/hid-core.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index ec7c2860c93e..a33e864a25f9 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2033,8 +2033,13 @@ int __hid_request(struct hid_device *hid, struct hid_report *report,
return ret;
}
- if (reqtype == HID_REQ_GET_REPORT)
- hid_input_report(hid, report->type, buf, ret, 0);
+ if (reqtype == HID_REQ_GET_REPORT) {
+ if (report->id == 0)
+ ret--;
+
+ if (ret > 0)
+ hid_input_report(hid, report->type, data_buf, ret, 0);
+ }
return 0;
}
--
2.56.0.385.gd3acb90ef8-goog