diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2014-12-11 19:02:45 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-12-12 03:36:20 -0500 |
commit | d1c7e29e8d276c669e8790bb8be9f505ddc48888 (patch) | |
tree | 4067652204d865084fe2c863e281b176a32e803e /drivers/hid/i2c-hid | |
parent | dff674168878fe7b6d8b9ad60d62295ec517de79 (diff) |
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 <gwendal@chromium.org>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/i2c-hid')
-rw-r--r-- | drivers/hid/i2c-hid/i2c-hid.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 747d54421e73..9c014803b460 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c | |||
@@ -369,7 +369,7 @@ static int i2c_hid_hwreset(struct i2c_client *client) | |||
369 | static void i2c_hid_get_input(struct i2c_hid *ihid) | 369 | static void i2c_hid_get_input(struct i2c_hid *ihid) |
370 | { | 370 | { |
371 | int ret, ret_size; | 371 | int ret, ret_size; |
372 | int size = le16_to_cpu(ihid->hdesc.wMaxInputLength); | 372 | int size = ihid->bufsize; |
373 | 373 | ||
374 | ret = i2c_master_recv(ihid->client, ihid->inbuf, size); | 374 | ret = i2c_master_recv(ihid->client, ihid->inbuf, size); |
375 | if (ret != size) { | 375 | if (ret != size) { |