Commit 760f7e7b authored by Jiri Kosina's avatar Jiri Kosina

Merge branch 'for-5.12/core' into for-linus

- improved handling of generic HID keyboard (no more splitting system
  and consumer controls away), in order to make it easier for userspace
  to figure out the details of the device easier. From Dmitry Torokhov.

- report data sanitization fixes from Will McVicker and Randy Dunlap
parents 88f38846 7c7d7ac7
...@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(hid_register_report); ...@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(hid_register_report);
* Register a new field for this report. * Register a new field for this report.
*/ */
static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages)
{ {
struct hid_field *field; struct hid_field *field;
...@@ -101,7 +101,7 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned ...@@ -101,7 +101,7 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
field = kzalloc((sizeof(struct hid_field) + field = kzalloc((sizeof(struct hid_field) +
usages * sizeof(struct hid_usage) + usages * sizeof(struct hid_usage) +
values * sizeof(unsigned)), GFP_KERNEL); usages * sizeof(unsigned)), GFP_KERNEL);
if (!field) if (!field)
return NULL; return NULL;
...@@ -300,7 +300,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign ...@@ -300,7 +300,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
usages = max_t(unsigned, parser->local.usage_index, usages = max_t(unsigned, parser->local.usage_index,
parser->global.report_count); parser->global.report_count);
field = hid_register_field(report, usages, parser->global.report_count); field = hid_register_field(report, usages);
if (!field) if (!field)
return 0; return 0;
...@@ -1307,6 +1307,9 @@ EXPORT_SYMBOL_GPL(hid_open_report); ...@@ -1307,6 +1307,9 @@ EXPORT_SYMBOL_GPL(hid_open_report);
static s32 snto32(__u32 value, unsigned n) static s32 snto32(__u32 value, unsigned n)
{ {
if (!value || !n)
return 0;
switch (n) { switch (n) {
case 8: return ((__s8)value); case 8: return ((__s8)value);
case 16: return ((__s16)value); case 16: return ((__s16)value);
......
...@@ -1856,6 +1856,16 @@ static struct hid_input *hidinput_match_application(struct hid_report *report) ...@@ -1856,6 +1856,16 @@ static struct hid_input *hidinput_match_application(struct hid_report *report)
list_for_each_entry(hidinput, &hid->inputs, list) { list_for_each_entry(hidinput, &hid->inputs, list) {
if (hidinput->application == report->application) if (hidinput->application == report->application)
return hidinput; return hidinput;
/*
* Keep SystemControl and ConsumerControl applications together
* with the main keyboard, if present.
*/
if ((report->application == HID_GD_SYSTEM_CONTROL ||
report->application == HID_CP_CONSUMER_CONTROL) &&
hidinput->application == HID_GD_KEYBOARD) {
return hidinput;
}
} }
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment