Both usbhid and i2c-hid are expecting the first byte of the incoming data to be the report ID. It should be set to 0 when the report ID is not used. Currently, we are not enforcing this, which means that if we enforce HID-BPF for LEDs, we will not be able to send them.
Note that the allocated buffer takes into account that extra byte, so this is safe to shift the data buffer by one. Signed-off-by: Benjamin Tissoires <[email protected]> --- drivers/hid/hid-input.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index d5308adb2894..eb84f63c51b8 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1830,9 +1830,9 @@ static void hidinput_led_worker(struct work_struct *work) led_work); struct hid_field *field; struct hid_report *report; + __u8 *buf, *data; int ret; u32 len; - __u8 *buf; field = hidinput_get_led_field(hid); if (!field) @@ -1863,7 +1863,14 @@ static void hidinput_led_worker(struct work_struct *work) if (!buf) return; - hid_output_report(report, buf); + data = buf; + if (!report->id) { + data = &buf[1]; + len++; + } + + hid_output_report(report, data); + /* synchronous output report */ ret = hid_hw_output_report(hid, buf, len); if (ret == -ENOSYS) -- 2.52.0

