summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/hid.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2015-03-27 12:45:47 +0100
committerGreg Kroah-Hartman <greg@kroah.com>2015-03-30 15:20:33 +0200
commit382145beb4a4bb057f17d5b411546b6b56fbacd1 (patch)
tree7ee653e71ac9ac14e43275669eb4d7aa466231d1 /drivers/staging/greybus/hid.c
parent36257f6b4e7671cb12f98d91a6ffdeabdc254d0c (diff)
downloadop-kernel-dev-382145beb4a4bb057f17d5b411546b6b56fbacd1.zip
op-kernel-dev-382145beb4a4bb057f17d5b411546b6b56fbacd1.tar.gz
greybus: hid: fix missing input verification of report events
Add minimal verification of incoming report size, before using it to determine what buffer and size to pass on to HID core. Add comment about protocol needing to be revisited. If we are going to be parsing the report data received, then those fields have to be defined in the Greybus specification at least. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/hid.c')
-rw-r--r--drivers/staging/greybus/hid.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/greybus/hid.c b/drivers/staging/greybus/hid.c
index a225813..8e32dfc 100644
--- a/drivers/staging/greybus/hid.c
+++ b/drivers/staging/greybus/hid.c
@@ -168,8 +168,12 @@ static void gb_hid_irq_handler(u8 type, struct gb_operation *op)
return;
}
+ /*
+ * FIXME: add report size to Greybus HID protocol if we need to parse
+ * it here.
+ */
size = request->report[0] | request->report[1] << 8;
- if (!size) {
+ if (size < 2 || size > op->request->payload_size - 2) {
dev_err(&connection->dev, "bad report size: %d\n", size);
return;
}
OpenPOWER on IntegriCloud