[PATCH 1/44] Fix hid-core for devices with #usages < #values

From: Vojtech Pavlik
Date: Tue Mar 16 2004 - 09:59:09 EST


You can pull this changeset from:
bk://kernel.bkbits.net/vojtech/input

===================================================================

ChangeSet@xxxxxxxxxxxx, 2004-01-26 13:15:32+01:00, jamesl@xxxxxxxxxxxxxxxx
input: Fix hid-core for devices that have less usages than values
in a hid report. We could iterate beyond the end of array of
usages before.


hid-core.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

===================================================================

diff -Nru a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
--- a/drivers/usb/input/hid-core.c Tue Mar 16 13:20:15 2004
+++ b/drivers/usb/input/hid-core.c Tue Mar 16 13:20:15 2004
@@ -224,6 +224,9 @@
offset = report->size;
report->size += parser->global.report_size * parser->global.report_count;

+ if (usages < parser->global.report_count)
+ usages = parser->global.report_count;
+
if (usages == 0)
return 0; /* ignore padding fields */

@@ -235,9 +238,13 @@
field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);

for (i = 0; i < usages; i++) {
- field->usage[i].hid = parser->local.usage[i];
+ int j = i;
+ /* Duplicate the last usage we parsed if we have excess values */
+ if (i >= parser->local.usage_index)
+ j = parser->local.usage_index - 1;
+ field->usage[i].hid = parser->local.usage[j];
field->usage[i].collection_index =
- parser->local.collection_index[i];
+ parser->local.collection_index[j];
}

field->maxusage = usages;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/