--- i2c-hid.c.orig	2015-09-03 11:28:05.988149512 +0200
+++ i2c-hid.c	2015-09-03 11:33:07.941099355 +0200
@@ -372,12 +372,20 @@ static int i2c_hid_hwreset(struct i2c_cl
 
 static void i2c_hid_get_input(struct i2c_hid *ihid)
 {
+	unsigned max_input_length = le16_to_cpu(ihid->hdesc.wMaxInputLength);
 	int ret, ret_size;
 	int size = le16_to_cpu(ihid->hdesc.wMaxInputLength);
 
 	if (size > ihid->bufsize)
 		size = ihid->bufsize;
 
+	/*
+	 * Take the input length from HID descriptor if it is available and
+	 * looks reasonable.
+	 */
+	if (max_input_length > 0)
+		size = min_t(unsigned, ihid->bufsize, max_input_length);
+
 	ret = i2c_master_recv(ihid->client, ihid->inbuf, size);
 	if (ret != size) {
 		if (ret < 0)
