diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-06 15:33:36 +0100 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2017-03-06 17:29:11 -0500 |
commit | e0fb4ae61143bb6b218aa8bab1730bb156c4d457 (patch) | |
tree | 1ca60f3e761422171589851fd81a77dc99063097 /drivers/hid/hid-cypress.c | |
parent | 63d75fa737a0bddfb815f7521eef58509e067264 (diff) |
HID: hid-cypress: validate length of report
[ Upstream commit 1ebb71143758f45dc0fa76e2f48429e13b16d110 ]
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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'drivers/hid/hid-cypress.c')
-rw-r--r-- | drivers/hid/hid-cypress.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c index c4ef3bc726e3..e299576004ce 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, if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX)) return rdesc; + if (*rsize < 4) + return rdesc; + for (i = 0; i < *rsize - 4; i++) if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) { __u8 tmp; |