Skip to content

Commit 4f15ee9

Browse files
author
Benjamin Tissoires
committed
HID: core: ensure the allocated report buffer can contain the reserved report ID
When the report ID is not used, the low level transport drivers expect the first byte to be 0. However, currently the allocated buffer not account for that extra byte, meaning that instead of having 8 guaranteed bytes for implement to be working, we only have 7. Reported-by: Alan Stern <[email protected]> Closes: https://lore.kernel.org/linux-input/[email protected]/ Cc: [email protected] Suggested-by: Alan Stern <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 04515e0 commit 4f15ee9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/hid/hid-core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,9 +1883,12 @@ u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags)
18831883
/*
18841884
* 7 extra bytes are necessary to achieve proper functionality
18851885
* of implement() working on 8 byte chunks
1886+
* 1 extra byte for the report ID if it is null (not used) so
1887+
* we can reserve that extra byte in the first position of the buffer
1888+
* when sending it to .raw_request()
18861889
*/
18871890

1888-
u32 len = hid_report_len(report) + 7;
1891+
u32 len = hid_report_len(report) + 7 + (report->id == 0);
18891892

18901893
return kzalloc(len, flags);
18911894
}

0 commit comments

Comments
 (0)