summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2014-12-12 03:02:45 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-16 17:59:48 +0300
commite788b6db966ab6ba895518af2042d5d9cc1989d5 (patch)
tree752e4106ccd24f4f2fe612d2a23c7837d1c8c639 /drivers/hid
parentdb8bf517310df9b82e95b6a335e648fb024a16fe (diff)
downloadlinux-e788b6db966ab6ba895518af2042d5d9cc1989d5.tar.xz
HID: i2c-hid: prevent buffer overflow in early IRQ
commit d1c7e29e8d276c669e8790bb8be9f505ddc48888 upstream. 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> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c2
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 ad6f7ee353b3..d6ea510dcded 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -370,7 +370,7 @@ static int i2c_hid_hwreset(struct i2c_client *client)
static void i2c_hid_get_input(struct i2c_hid *ihid)
{
int ret, ret_size;
- int size = le16_to_cpu(ihid->hdesc.wMaxInputLength);
+ int size = ihid->bufsize;
ret = i2c_master_recv(ihid->client, ihid->inbuf, size);
if (ret != size) {