[PATCH v4 5/7] HID: asus: Do not send feature reports larger than declared

From: Paolo Pisati

Date: Tue Oct 20 2026 - 05:31:28 EST


The keyboard backlight and Fn-lock commands are sent as 64 byte
feature reports, the size of report 0x5a on the ROG keyboards. The
Zenbook Duo keyboards declare feature report 0x5a with 15 data bytes,
16 with the report ID, and do not answer writes larger than that: the
control transfer times out over USB and fails with -EIO over
Bluetooth, so the backlight cannot be set, while the 16 byte handshake
goes through.

Cap feature report writes at the length the device declares for the
report, when it declares it. hid_report_len() counts the report ID, so
the handshake and the other commands up to that size are sent as they
are.

Signed-off-by: Paolo Pisati <p.pisati@xxxxxxxxx>
Tested-by: Rebecca Mara Müller <rebecca.mara@xxxxxxxxx> # UX8407AA
Reviewed-by: Denis Benato <denis.benato@xxxxxxxxx>
---
drivers/hid/hid-asus.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 739637f1964a..65ce31a5489a 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -631,6 +631,19 @@ static int asus_raw_event(struct hid_device *hdev,

static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t buf_size)
{
+ struct hid_report *report;
+
+ /*
+ * Do not send more than the declared size of the report, report ID
+ * included. Sizes differ between devices: most ROG keyboards declare
+ * 64 bytes and the XG Mobile 300, while the Zenbook Duo keyboards, like
+ * the touchpads, declare 16 for report 0x5a, the size of the handshake,
+ * and do not answer the 64 byte writes sized for the ROG keyboards.
+ */
+ report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[buf[0]];
+ if (report)
+ buf_size = min_t(size_t, buf_size, hid_report_len(report));
+
u8 *dmabuf __free(kfree) = kmemdup(buf, buf_size, GFP_KERNEL);
if (!dmabuf)
return -ENOMEM;
--
2.43.0