diff options
author | Jiri Kosina <jkosina@suse.cz> | 2015-09-01 16:23:13 +0300 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2015-09-01 16:23:13 +0300 |
commit | 3e097d1271ecdff2f251a54ddfc5eaa1f9821e96 (patch) | |
tree | d84a437e8ed4c3e71521c739952ba96fd02b3781 /drivers/hid/hid-core.c | |
parent | 0be017120b80f0fe3da9a8239f989a27e54828f2 (diff) | |
parent | c9b57724b38d4c1555ee49418be3d76801e3327c (diff) | |
download | linux-3e097d1271ecdff2f251a54ddfc5eaa1f9821e96.tar.xz |
Merge branches 'for-4.2/upstream-fixes-devm-fixed' and 'for-4.3/upstream' into for-linus
Diffstat (limited to 'drivers/hid/hid-core.c')
-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) { __u32 data; unsigned n; + __u32 count; data = item_udata(item); @@ -490,6 +491,24 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) if (item->size <= 2) data = (parser->global.usage_page << 16) + data; + count = data - parser->local.usage_minimum; + if (count + parser->local.usage_index >= HID_MAX_USAGES) { + /* + * We do not warn if the name is not set, we are + * actually pre-scanning the device. + */ + if (dev_name(&parser->device->dev)) + hid_warn(parser->device, + "ignoring exceeding usage max\n"); + data = HID_MAX_USAGES - parser->local.usage_index + + parser->local.usage_minimum - 1; + if (data <= 0) { + hid_err(parser->device, + "no more usage index available\n"); + return -1; + } + } + for (n = parser->local.usage_minimum; n <= data; n++) if (hid_add_usage(parser, n)) { dbg_hid("hid_add_usage failed\n"); |