diff options
| -rw-r--r-- | drivers/hid/hid-core.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 157c62775053..b403fe2c5cbe 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
| @@ -427,6 +427,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) | |||
| 427 | { | 427 | { |
| 428 | __u32 data; | 428 | __u32 data; |
| 429 | unsigned n; | 429 | unsigned n; |
| 430 | __u32 count; | ||
| 430 | 431 | ||
| 431 | data = item_udata(item); | 432 | data = item_udata(item); |
| 432 | 433 | ||
| @@ -490,6 +491,24 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) | |||
| 490 | if (item->size <= 2) | 491 | if (item->size <= 2) |
| 491 | data = (parser->global.usage_page << 16) + data; | 492 | data = (parser->global.usage_page << 16) + data; |
| 492 | 493 | ||
| 494 | count = data - parser->local.usage_minimum; | ||
| 495 | if (count + parser->local.usage_index >= HID_MAX_USAGES) { | ||
| 496 | /* | ||
| 497 | * We do not warn if the name is not set, we are | ||
| 498 | * actually pre-scanning the device. | ||
| 499 | */ | ||
| 500 | if (dev_name(&parser->device->dev)) | ||
| 501 | hid_warn(parser->device, | ||
| 502 | "ignoring exceeding usage max\n"); | ||
| 503 | data = HID_MAX_USAGES - parser->local.usage_index + | ||
| 504 | parser->local.usage_minimum - 1; | ||
| 505 | if (data <= 0) { | ||
| 506 | hid_err(parser->device, | ||
| 507 | "no more usage index available\n"); | ||
| 508 | return -1; | ||
| 509 | } | ||
| 510 | } | ||
| 511 | |||
| 493 | for (n = parser->local.usage_minimum; n <= data; n++) | 512 | for (n = parser->local.usage_minimum; n <= data; n++) |
| 494 | if (hid_add_usage(parser, n)) { | 513 | if (hid_add_usage(parser, n)) { |
| 495 | dbg_hid("hid_add_usage failed\n"); | 514 | dbg_hid("hid_add_usage failed\n"); |
