Skip to content

Commit 0365fb6

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID fixes from Jiri Kosina: - HID++ device support regression fixes (race condition during cleanup, device detection fix, opps fix) from Andrey Smirnov - disable PM on i2c-hid, as it's causing problems with a lot of devices; other OSes apparently don't implement/enable it either; from Kai-Heng Feng - error handling fix in intel-ish driver, from Zhang Lixu - syzbot fuzzer fix for HID core code from Alan Stern - a few other tiny fixups (printk message cleanup, new device ID) * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: HID: i2c-hid: add Trekstor Primebook C11B to descriptor override HID: logitech-hidpp: do all FF cleanup in hidpp_ff_destroy() HID: logitech-hidpp: rework device validation HID: logitech-hidpp: split g920_get_config() HID: i2c-hid: Remove runtime power management HID: intel-ish-hid: fix wrong error handling in ishtp_cl_alloc_tx_ring() HID: google: add magnemite/masterball USB ids HID: Fix assumption that devices have inputs HID: prodikeys: make array keys static const, makes object smaller HID: fix error message in hid_open_report()
2 parents 9e5eefb + 09f3dbe commit 0365fb6

21 files changed

+297
-259
lines changed

drivers/hid/hid-axff.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,20 @@ static int axff_init(struct hid_device *hid)
6363
{
6464
struct axff_device *axff;
6565
struct hid_report *report;
66-
struct hid_input *hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
66+
struct hid_input *hidinput;
6767
struct list_head *report_list =&hid->report_enum[HID_OUTPUT_REPORT].report_list;
68-
struct input_dev *dev = hidinput->input;
68+
struct input_dev *dev;
6969
int field_count = 0;
7070
int i, j;
7171
int error;
7272

73+
if (list_empty(&hid->inputs)) {
74+
hid_err(hid, "no inputs found\n");
75+
return -ENODEV;
76+
}
77+
hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
78+
dev = hidinput->input;
79+
7380
if (list_empty(report_list)) {
7481
hid_err(hid, "no output reports found\n");
7582
return -ENODEV;

drivers/hid/hid-core.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,7 @@ int hid_open_report(struct hid_device *device)
11391139
__u8 *start;
11401140
__u8 *buf;
11411141
__u8 *end;
1142+
__u8 *next;
11421143
int ret;
11431144
static int (*dispatch_type[])(struct hid_parser *parser,
11441145
struct hid_item *item) = {
@@ -1192,7 +1193,8 @@ int hid_open_report(struct hid_device *device)
11921193
device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
11931194

11941195
ret = -EINVAL;
1195-
while ((start = fetch_item(start, end, &item)) != NULL) {
1196+
while ((next = fetch_item(start, end, &item)) != NULL) {
1197+
start = next;
11961198

11971199
if (item.format != HID_ITEM_FORMAT_SHORT) {
11981200
hid_err(device, "unexpected long global item\n");
@@ -1230,7 +1232,8 @@ int hid_open_report(struct hid_device *device)
12301232
}
12311233
}
12321234

1233-
hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
1235+
hid_err(device, "item fetching failed at offset %u/%u\n",
1236+
size - (unsigned int)(end - start), size);
12341237
err:
12351238
kfree(parser->collection_stack);
12361239
alloc_err:

drivers/hid/hid-dr.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,19 @@ static int drff_init(struct hid_device *hid)
7575
{
7676
struct drff_device *drff;
7777
struct hid_report *report;
78-
struct hid_input *hidinput = list_first_entry(&hid->inputs,
79-
struct hid_input, list);
78+
struct hid_input *hidinput;
8079
struct list_head *report_list =
8180
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
82-
struct input_dev *dev = hidinput->input;
81+
struct input_dev *dev;
8382
int error;
8483

84+
if (list_empty(&hid->inputs)) {
85+
hid_err(hid, "no inputs found\n");
86+
return -ENODEV;
87+
}
88+
hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
89+
dev = hidinput->input;
90+
8591
if (list_empty(report_list)) {
8692
hid_err(hid, "no output reports found\n");
8793
return -ENODEV;

drivers/hid/hid-emsff.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ static int emsff_init(struct hid_device *hid)
4747
{
4848
struct emsff_device *emsff;
4949
struct hid_report *report;
50-
struct hid_input *hidinput = list_first_entry(&hid->inputs,
51-
struct hid_input, list);
50+
struct hid_input *hidinput;
5251
struct list_head *report_list =
5352
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
54-
struct input_dev *dev = hidinput->input;
53+
struct input_dev *dev;
5554
int error;
5655

56+
if (list_empty(&hid->inputs)) {
57+
hid_err(hid, "no inputs found\n");
58+
return -ENODEV;
59+
}
60+
hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
61+
dev = hidinput->input;
62+
5763
if (list_empty(report_list)) {
5864
hid_err(hid, "no output reports found\n");
5965
return -ENODEV;

drivers/hid/hid-gaff.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *hid)
6464
{
6565
struct gaff_device *gaff;
6666
struct hid_report *report;
67-
struct hid_input *hidinput = list_entry(hid->inputs.next,
68-
struct hid_input, list);
67+
struct hid_input *hidinput;
6968
struct list_head *report_list =
7069
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
7170
struct list_head *report_ptr = report_list;
72-
struct input_dev *dev = hidinput->input;
71+
struct input_dev *dev;
7372
int error;
7473

74+
if (list_empty(&hid->inputs)) {
75+
hid_err(hid, "no inputs found\n");
76+
return -ENODEV;
77+
}
78+
hidinput = list_entry(hid->inputs.next, struct hid_input, list);
79+
dev = hidinput->input;
80+
7581
if (list_empty(report_list)) {
7682
hid_err(hid, "no output reports found\n");
7783
return -ENODEV;

drivers/hid/hid-google-hammer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@ static int hammer_probe(struct hid_device *hdev,
469469
static const struct hid_device_id hammer_devices[] = {
470470
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
471471
USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) },
472+
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
473+
USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MAGNEMITE) },
474+
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
475+
USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MASTERBALL) },
472476
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
473477
USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) },
474478
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,

drivers/hid/hid-holtekff.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,19 @@ static int holtekff_init(struct hid_device *hid)
124124
{
125125
struct holtekff_device *holtekff;
126126
struct hid_report *report;
127-
struct hid_input *hidinput = list_entry(hid->inputs.next,
128-
struct hid_input, list);
127+
struct hid_input *hidinput;
129128
struct list_head *report_list =
130129
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
131-
struct input_dev *dev = hidinput->input;
130+
struct input_dev *dev;
132131
int error;
133132

133+
if (list_empty(&hid->inputs)) {
134+
hid_err(hid, "no inputs found\n");
135+
return -ENODEV;
136+
}
137+
hidinput = list_entry(hid->inputs.next, struct hid_input, list);
138+
dev = hidinput->input;
139+
134140
if (list_empty(report_list)) {
135141
hid_err(hid, "no output report found\n");
136142
return -ENODEV;

drivers/hid/hid-ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@
476476
#define USB_DEVICE_ID_GOOGLE_STAFF 0x502b
477477
#define USB_DEVICE_ID_GOOGLE_WAND 0x502d
478478
#define USB_DEVICE_ID_GOOGLE_WHISKERS 0x5030
479+
#define USB_DEVICE_ID_GOOGLE_MASTERBALL 0x503c
480+
#define USB_DEVICE_ID_GOOGLE_MAGNEMITE 0x503d
479481

480482
#define USB_VENDOR_ID_GOTOP 0x08f2
481483
#define USB_DEVICE_ID_SUPER_Q2 0x007f

drivers/hid/hid-lg2ff.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@ int lg2ff_init(struct hid_device *hid)
5050
{
5151
struct lg2ff_device *lg2ff;
5252
struct hid_report *report;
53-
struct hid_input *hidinput = list_entry(hid->inputs.next,
54-
struct hid_input, list);
55-
struct input_dev *dev = hidinput->input;
53+
struct hid_input *hidinput;
54+
struct input_dev *dev;
5655
int error;
5756

57+
if (list_empty(&hid->inputs)) {
58+
hid_err(hid, "no inputs found\n");
59+
return -ENODEV;
60+
}
61+
hidinput = list_entry(hid->inputs.next, struct hid_input, list);
62+
dev = hidinput->input;
63+
5864
/* Check that the report looks ok */
5965
report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7);
6066
if (!report)

drivers/hid/hid-lg3ff.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,19 @@ static const signed short ff3_joystick_ac[] = {
117117

118118
int lg3ff_init(struct hid_device *hid)
119119
{
120-
struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
121-
struct input_dev *dev = hidinput->input;
120+
struct hid_input *hidinput;
121+
struct input_dev *dev;
122122
const signed short *ff_bits = ff3_joystick_ac;
123123
int error;
124124
int i;
125125

126+
if (list_empty(&hid->inputs)) {
127+
hid_err(hid, "no inputs found\n");
128+
return -ENODEV;
129+
}
130+
hidinput = list_entry(hid->inputs.next, struct hid_input, list);
131+
dev = hidinput->input;
132+
126133
/* Check that the report looks ok */
127134
if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35))
128135
return -ENODEV;

0 commit comments

Comments
 (0)