aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-core.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index dcd60eb3d5ea..2ac13ca6edaa 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -63,6 +63,8 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type,
63 struct hid_report_enum *report_enum = device->report_enum + type; 63 struct hid_report_enum *report_enum = device->report_enum + type;
64 struct hid_report *report; 64 struct hid_report *report;
65 65
66 if (id >= HID_MAX_IDS)
67 return NULL;
66 if (report_enum->report_id_hash[id]) 68 if (report_enum->report_id_hash[id])
67 return report_enum->report_id_hash[id]; 69 return report_enum->report_id_hash[id];
68 70
@@ -404,8 +406,10 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
404 406
405 case HID_GLOBAL_ITEM_TAG_REPORT_ID: 407 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
406 parser->global.report_id = item_udata(item); 408 parser->global.report_id = item_udata(item);
407 if (parser->global.report_id == 0) { 409 if (parser->global.report_id == 0 ||
408 hid_err(parser->device, "report_id 0 is invalid\n"); 410 parser->global.report_id >= HID_MAX_IDS) {
411 hid_err(parser->device, "report_id %u is invalid\n",
412 parser->global.report_id);
409 return -1; 413 return -1;
410 } 414 }
411 return 0; 415 return 0;
@@ -575,7 +579,7 @@ static void hid_close_report(struct hid_device *device)
575 for (i = 0; i < HID_REPORT_TYPES; i++) { 579 for (i = 0; i < HID_REPORT_TYPES; i++) {
576 struct hid_report_enum *report_enum = device->report_enum + i; 580 struct hid_report_enum *report_enum = device->report_enum + i;
577 581
578 for (j = 0; j < 256; j++) { 582 for (j = 0; j < HID_MAX_IDS; j++) {
579 struct hid_report *report = report_enum->report_id_hash[j]; 583 struct hid_report *report = report_enum->report_id_hash[j];
580 if (report) 584 if (report)
581 hid_free_report(report); 585 hid_free_report(report);