From: Greg Kroah-Hartman Date: Fri, 6 Jan 2017 14:33:36 +0000 (+0100) Subject: HID: hid-cypress: validate length of report X-Git-Tag: Ubuntu-5.4-5.4.0-11.14~8636^2~1 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=1ebb71143758f45dc0fa76e2f48429e13b16d110;p=mirror_ubuntu-focal-kernel.git 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 Tested-by: Benoit Camredon Cc: stable Signed-off-by: Greg Kroah-Hartman Signed-off-by: Jiri Kosina --- 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, 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) { rdesc[i] = 0x19;