mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-24 05:01:03 +02:00
HID: core: Provide new max_buffer_size attribute to over-ride the default
Presently, when a report is processed, its proposed size, provided by the user of the API (as Report Size * Report Count) is compared against the subsystem default HID_MAX_BUFFER_SIZE (16k). However, some low-level HID drivers allocate a reduced amount of memory to their buffers (e.g. UHID only allocates UHID_DATA_MAX (4k) buffers), rending this check inadequate in some cases. In these circumstances, if the received report ends up being smaller than the proposed report size, the remainder of the buffer is zeroed. That is, the space between sizeof(csize) (size of the current report) and the rsize (size proposed i.e. Report Size * Report Count), which can be handled up to HID_MAX_BUFFER_SIZE (16k). Meaning that memset() shoots straight past the end of the buffer boundary and starts zeroing out in-use values, often resulting in calamity. This patch introduces a new variable into 'struct hid_ll_driver' where individual low-level drivers can over-ride the default maximum value of HID_MAX_BUFFER_SIZE (16k) with something more sympathetic to the interface. Signed-off-by: Lee Jones <lee@kernel.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
@@ -834,6 +834,7 @@ struct hid_driver {
|
||||
* @output_report: send output report to device
|
||||
* @idle: send idle request to device
|
||||
* @may_wakeup: return if device may act as a wakeup source during system-suspend
|
||||
* @max_buffer_size: over-ride maximum data buffer size (default: HID_MAX_BUFFER_SIZE)
|
||||
*/
|
||||
struct hid_ll_driver {
|
||||
int (*start)(struct hid_device *hdev);
|
||||
@@ -859,6 +860,8 @@ struct hid_ll_driver {
|
||||
|
||||
int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
|
||||
bool (*may_wakeup)(struct hid_device *hdev);
|
||||
|
||||
unsigned int max_buffer_size;
|
||||
};
|
||||
|
||||
extern bool hid_is_usb(const struct hid_device *hdev);
|
||||
|
Reference in New Issue
Block a user