[PATCH v2 5/7] HID: asus: Do not send feature reports larger than declared
From: Paolo Pisati
Date: Fri Oct 09 2026 - 11:38:06 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 report 0x5a as a 15 byte feature report
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.
Assisted-by: LLM
Signed-off-by: Paolo Pisati <p.pisati@xxxxxxxxx>
---
drivers/hid/hid-asus.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index d8a931290c9a..9e80a2bb54c3 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -618,6 +618,17 @@ 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: the
+ * Zenbook Duo keyboards declare report 0x5a as 15 bytes long 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