diff options
author | Benjamin Tissoires <benjamin.tissoires@gmail.com> | 2012-12-05 09:02:53 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2012-12-06 04:54:26 -0500 |
commit | 27174cff8fcfcb3a60a3e7225cc627f6a4b7f827 (patch) | |
tree | d4992c47aedd6710f0facb90bc463a5219693c59 /drivers/hid/i2c-hid | |
parent | addb114dd646f9386f5845cdb059f22a497f9a9d (diff) |
HID: i2c-hid: fix memory corruption due to missing hid declaration
HID descriptors contains 4 bytes of reserved field.
The previous implementation was overriding the next fields in struct i2c_hid.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Jean Delvare <khali@linux-fr.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 | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 7062df21da52..34cca428a6a9 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c | |||
@@ -69,6 +69,7 @@ struct i2c_hid_desc { | |||
69 | __le16 wVendorID; | 69 | __le16 wVendorID; |
70 | __le16 wProductID; | 70 | __le16 wProductID; |
71 | __le16 wVersionID; | 71 | __le16 wVersionID; |
72 | __le32 reserved; | ||
72 | } __packed; | 73 | } __packed; |
73 | 74 | ||
74 | struct i2c_hid_cmd { | 75 | struct i2c_hid_cmd { |
@@ -776,7 +777,13 @@ static int __devinit i2c_hid_fetch_hid_descriptor(struct i2c_hid *ihid) | |||
776 | } | 777 | } |
777 | 778 | ||
778 | dsize = le16_to_cpu(hdesc->wHIDDescLength); | 779 | dsize = le16_to_cpu(hdesc->wHIDDescLength); |
779 | if (!dsize || dsize > HID_MAX_DESCRIPTOR_SIZE) { | 780 | /* |
781 | * the size of the HID descriptor should at least contain | ||
782 | * its size and the bcdVersion (4 bytes), and should not be greater | ||
783 | * than sizeof(struct i2c_hid_desc) as we directly fill this struct | ||
784 | * through i2c_hid_command. | ||
785 | */ | ||
786 | if (dsize < 4 || dsize > sizeof(struct i2c_hid_desc)) { | ||
780 | dev_err(&client->dev, "weird size of HID descriptor (%u)\n", | 787 | dev_err(&client->dev, "weird size of HID descriptor (%u)\n", |
781 | dsize); | 788 | dsize); |
782 | return -ENODEV; | 789 | return -ENODEV; |