aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-06 09:33:36 -0500
committerJiri Kosina <jkosina@suse.cz>2017-01-06 10:06:43 -0500
commit1ebb71143758f45dc0fa76e2f48429e13b16d110 (patch)
tree807bc3a12427e4334d2c54716759e26ac2c3ebc1
parent08f9572671c8047e7234cbf150869aa3c3d59a97 (diff)
HID: hid-cypress: validate length of report
Make sure we have enough of a report structure to validate before looking at it. Reported-by: Benoit Camredon <benoit.camredon@airbus.com> Tested-by: Benoit Camredon <benoit.camredon@airbus.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-cypress.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c
index 1b764d1745f3..1689568b597d 100644
--- a/drivers/hid/hid-cypress.c
+++ b/drivers/hid/hid-cypress.c
@@ -39,6 +39,9 @@ static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
39 if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX)) 39 if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX))
40 return rdesc; 40 return rdesc;
41 41
42 if (*rsize < 4)
43 return rdesc;
44
42 for (i = 0; i < *rsize - 4; i++) 45 for (i = 0; i < *rsize - 4; i++)
43 if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) { 46 if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) {
44 rdesc[i] = 0x19; 47 rdesc[i] = 0x19;