Skip to content

Commit d1c7e29

Browse files
gwendalcrJiri Kosina
authored and
Jiri Kosina
committed
HID: i2c-hid: prevent buffer overflow in early IRQ
Before ->start() is called, bufsize size is set to HID_MIN_BUFFER_SIZE, 64 bytes. While processing the IRQ, we were asking to receive up to wMaxInputLength bytes, which can be bigger than 64 bytes. Later, when ->start is run, a proper bufsize will be calculated. Given wMaxInputLength is said to be unreliable in other part of the code, set to receive only what we can even if it results in truncated reports. Signed-off-by: Gwendal Grignou <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Cc: [email protected] Signed-off-by: Jiri Kosina <[email protected]>
1 parent dff6741 commit d1c7e29

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hid/i2c-hid/i2c-hid.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static int i2c_hid_hwreset(struct i2c_client *client)
369369
static void i2c_hid_get_input(struct i2c_hid *ihid)
370370
{
371371
int ret, ret_size;
372-
int size = le16_to_cpu(ihid->hdesc.wMaxInputLength);
372+
int size = ihid->bufsize;
373373

374374
ret = i2c_master_recv(ihid->client, ihid->inbuf, size);
375375
if (ret != size) {

0 commit comments

Comments
 (0)