Skip to content

Commit a1f7642

Browse files
committed
Merge tag 'for-linus-2022083101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID fixes from Jiri Kosina: - NULL pointer dereference fix for Steam driver (Lee Jones) - memory leak fix for hidraw (Karthik Alapati) - regression fix for functionality of some UCLogic tables (Benjamin Tissoires) - a few new device IDs and device-specific quirks * tag 'for-linus-2022083101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: HID: nintendo: fix rumble worker null pointer deref HID: intel-ish-hid: ipc: Add Meteor Lake PCI device ID HID: input: fix uclogic tablets HID: Add Apple Touchbar on T2 Macs in hid_have_special_driver list HID: add Lenovo Yoga C630 battery quirk HID: AMD_SFH: Add a DMI quirk entry for Chromebooks HID: thrustmaster: Add sparco wheel and fix array length hid: intel-ish-hid: ishtp: Fix ishtp client sending disordered message HID: ishtp-hid-clientHID: ishtp-hid-client: Fix comment typo HID: asus: ROG NKey: Ignore portion of 0x5a report HID: hidraw: fix memory leak in hidraw_release() HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report
2 parents 2361d38 + 1ff89e0 commit a1f7642

File tree

13 files changed

+96
-34
lines changed

13 files changed

+96
-34
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,29 @@ int amd_sfh_irq_init(struct amd_mp2_dev *privdata)
288288
return 0;
289289
}
290290

291+
static const struct dmi_system_id dmi_nodevs[] = {
292+
{
293+
/*
294+
* Google Chromebooks use Chrome OS Embedded Controller Sensor
295+
* Hub instead of Sensor Hub Fusion and leaves MP2
296+
* uninitialized, which disables all functionalities, even
297+
* including the registers necessary for feature detections.
298+
*/
299+
.matches = {
300+
DMI_MATCH(DMI_SYS_VENDOR, "Google"),
301+
},
302+
},
303+
{ }
304+
};
305+
291306
static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
292307
{
293308
struct amd_mp2_dev *privdata;
294309
int rc;
295310

311+
if (dmi_first_match(dmi_nodevs))
312+
return -ENODEV;
313+
296314
privdata = devm_kzalloc(&pdev->dev, sizeof(*privdata), GFP_KERNEL);
297315
if (!privdata)
298316
return -ENOMEM;

drivers/hid/hid-asus.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,13 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
12121212
rdesc = new_rdesc;
12131213
}
12141214

1215+
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD &&
1216+
*rsize == 331 && rdesc[190] == 0x85 && rdesc[191] == 0x5a &&
1217+
rdesc[204] == 0x95 && rdesc[205] == 0x05) {
1218+
hid_info(hdev, "Fixing up Asus N-KEY keyb report descriptor\n");
1219+
rdesc[205] = 0x01;
1220+
}
1221+
12151222
return rdesc;
12161223
}
12171224

drivers/hid/hid-ids.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@
185185
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 0x029c
186186
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 0x029a
187187
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 0x029f
188+
#define USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT 0x8102
189+
#define USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY 0x8302
188190

189191
#define USB_VENDOR_ID_ASUS 0x0486
190192
#define USB_DEVICE_ID_ASUS_T91MT 0x0185
@@ -414,6 +416,7 @@
414416
#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706
415417
#define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A
416418
#define I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN 0x2A1C
419+
#define I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN 0x279F
417420

418421
#define USB_VENDOR_ID_ELECOM 0x056e
419422
#define USB_DEVICE_ID_ELECOM_BM084 0x0061

drivers/hid/hid-input.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ static const struct hid_device_id hid_battery_quirks[] = {
383383
HID_BATTERY_QUIRK_IGNORE },
384384
{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN),
385385
HID_BATTERY_QUIRK_IGNORE },
386+
{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN),
387+
HID_BATTERY_QUIRK_IGNORE },
386388
{}
387389
};
388390

@@ -1532,7 +1534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
15321534
* assume ours
15331535
*/
15341536
if (!report->tool)
1535-
hid_report_set_tool(report, input, usage->code);
1537+
report->tool = usage->code;
1538+
1539+
/* drivers may have changed the value behind our back, resend it */
1540+
hid_report_set_tool(report, input, report->tool);
15361541
} else {
15371542
hid_report_release_tool(report, input, usage->code);
15381543
}

drivers/hid/hid-nintendo.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,7 @@ static void joycon_parse_report(struct joycon_ctlr *ctlr,
12211221

12221222
spin_lock_irqsave(&ctlr->lock, flags);
12231223
if (IS_ENABLED(CONFIG_NINTENDO_FF) && rep->vibrator_report &&
1224+
ctlr->ctlr_state != JOYCON_CTLR_STATE_REMOVED &&
12241225
(msecs - ctlr->rumble_msecs) >= JC_RUMBLE_PERIOD_MS &&
12251226
(ctlr->rumble_queue_head != ctlr->rumble_queue_tail ||
12261227
ctlr->rumble_zero_countdown > 0)) {
@@ -1545,12 +1546,13 @@ static int joycon_set_rumble(struct joycon_ctlr *ctlr, u16 amp_r, u16 amp_l,
15451546
ctlr->rumble_queue_head = 0;
15461547
memcpy(ctlr->rumble_data[ctlr->rumble_queue_head], data,
15471548
JC_RUMBLE_DATA_SIZE);
1548-
spin_unlock_irqrestore(&ctlr->lock, flags);
15491549

15501550
/* don't wait for the periodic send (reduces latency) */
1551-
if (schedule_now)
1551+
if (schedule_now && ctlr->ctlr_state != JOYCON_CTLR_STATE_REMOVED)
15521552
queue_work(ctlr->rumble_queue, &ctlr->rumble_worker);
15531553

1554+
spin_unlock_irqrestore(&ctlr->lock, flags);
1555+
15541556
return 0;
15551557
}
15561558

drivers/hid/hid-quirks.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
314314
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
315315
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) },
316316
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021) },
317+
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) },
318+
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) },
317319
#endif
318320
#if IS_ENABLED(CONFIG_HID_APPLEIR)
319321
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },

drivers/hid/hid-steam.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ static int steam_recv_report(struct steam_device *steam,
134134
int ret;
135135

136136
r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0];
137+
if (!r) {
138+
hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n");
139+
return -EINVAL;
140+
}
141+
137142
if (hid_report_len(r) < 64)
138143
return -EINVAL;
139144

@@ -165,6 +170,11 @@ static int steam_send_report(struct steam_device *steam,
165170
int ret;
166171

167172
r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0];
173+
if (!r) {
174+
hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n");
175+
return -EINVAL;
176+
}
177+
168178
if (hid_report_len(r) < 64)
169179
return -EINVAL;
170180

drivers/hid/hid-thrustmaster.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ static const struct tm_wheel_info tm_wheels_infos[] = {
6767
{0x0200, 0x0005, "Thrustmaster T300RS (Missing Attachment)"},
6868
{0x0206, 0x0005, "Thrustmaster T300RS"},
6969
{0x0209, 0x0005, "Thrustmaster T300RS (Open Wheel Attachment)"},
70+
{0x020a, 0x0005, "Thrustmaster T300RS (Sparco R383 Mod)"},
7071
{0x0204, 0x0005, "Thrustmaster T300 Ferrari Alcantara Edition"},
7172
{0x0002, 0x0002, "Thrustmaster T500RS"}
7273
//{0x0407, 0x0001, "Thrustmaster TMX"}
7374
};
7475

75-
static const uint8_t tm_wheels_infos_length = 4;
76+
static const uint8_t tm_wheels_infos_length = 7;
7677

7778
/*
7879
* This structs contains (in little endian) the response data

drivers/hid/hidraw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ static int hidraw_release(struct inode * inode, struct file * file)
350350
down_write(&minors_rwsem);
351351

352352
spin_lock_irqsave(&hidraw_table[minor]->list_lock, flags);
353+
for (int i = list->tail; i < list->head; i++)
354+
kfree(list->buffer[i].value);
353355
list_del(&list->node);
354356
spin_unlock_irqrestore(&hidraw_table[minor]->list_lock, flags);
355357
kfree(list);

drivers/hid/intel-ish-hid/ipc/hw-ish.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define ADL_P_DEVICE_ID 0x51FC
3333
#define ADL_N_DEVICE_ID 0x54FC
3434
#define RPL_S_DEVICE_ID 0x7A78
35+
#define MTL_P_DEVICE_ID 0x7E45
3536

3637
#define REVISION_ID_CHT_A0 0x6
3738
#define REVISION_ID_CHT_Ax_SI 0x0

0 commit comments

Comments
 (0)