Skip to content

Commit 48976c0

Browse files
committed
Merge tag 'hid-for-linus-2026030601' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID fixes from Benjamin Tissoires: - fix a few memory leaks (Günther Noack) - fix potential kernel crashes in cmedia, creative-sb0540 and zydacron (Greg Kroah-Hartman) - fix NULL pointer dereference in pidff (Tomasz Pakuła) - fix battery reporting for Apple Magic Trackpad 2 (Julius Lehmann) - mcp2221 proper handling of failed read operation (Romain Sioen) - various device quirks / device ID additions * tag 'hid-for-linus-2026030601' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: HID: mcp2221: cancel last I2C command on read error HID: asus: add xg mobile 2023 external hardware support HID: multitouch: Keep latency normal on deactivate for reactivation gesture HID: apple: Add EPOMAKER TH87 to the non-apple keyboards list HID: intel-ish-hid: ipc: Add Nova Lake-H/S PCI device IDs selftests: hid: tests: test_wacom_generic: add tests for display devices and opaque devices HID: multitouch: new class MT_CLS_EGALAX_P80H84 HID: magicmouse: fix battery reporting for Apple Magic Trackpad 2 HID: pidff: Fix condition effect bit clearing HID: Add HID_CLAIMED_INPUT guards in raw_event callbacks missing them HID: asus: avoid memory leak in asus_report_fixup() HID: magicmouse: avoid memory leak in magicmouse_report_fixup() HID: apple: avoid memory leak in apple_report_fixup() HID: Document memory allocation properties of report_fixup()
2 parents 54de8b8 + e31b556 commit 48976c0

14 files changed

Lines changed: 112 additions & 36 deletions

File tree

drivers/hid/hid-apple.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ static const struct apple_non_apple_keyboard non_apple_keyboards[] = {
365365
{ "A3R" },
366366
{ "hfd.cn" },
367367
{ "WKB603" },
368+
{ "TH87" }, /* EPOMAKER TH87 BT mode */
369+
{ "HFD Epomaker TH87" }, /* EPOMAKER TH87 USB mode */
370+
{ "2.4G Wireless Receiver" }, /* EPOMAKER TH87 dongle */
368371
};
369372

370373
static bool apple_is_non_apple_keyboard(struct hid_device *hdev)
@@ -686,9 +689,7 @@ static const __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
686689
hid_info(hdev,
687690
"fixing up Magic Keyboard battery report descriptor\n");
688691
*rsize = *rsize - 1;
689-
rdesc = kmemdup(rdesc + 1, *rsize, GFP_KERNEL);
690-
if (!rdesc)
691-
return NULL;
692+
rdesc = rdesc + 1;
692693

693694
rdesc[0] = 0x05;
694695
rdesc[1] = 0x01;

drivers/hid/hid-asus.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,14 +1399,21 @@ static const __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
13991399
*/
14001400
if (*rsize == rsize_orig &&
14011401
rdesc[offs] == 0x09 && rdesc[offs + 1] == 0x76) {
1402-
*rsize = rsize_orig + 1;
1403-
rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL);
1404-
if (!rdesc)
1405-
return NULL;
1402+
__u8 *new_rdesc;
1403+
1404+
new_rdesc = devm_kzalloc(&hdev->dev, rsize_orig + 1,
1405+
GFP_KERNEL);
1406+
if (!new_rdesc)
1407+
return rdesc;
14061408

14071409
hid_info(hdev, "Fixing up %s keyb report descriptor\n",
14081410
drvdata->quirks & QUIRK_T100CHI ?
14091411
"T100CHI" : "T90CHI");
1412+
1413+
memcpy(new_rdesc, rdesc, rsize_orig);
1414+
*rsize = rsize_orig + 1;
1415+
rdesc = new_rdesc;
1416+
14101417
memmove(rdesc + offs + 4, rdesc + offs + 2, 12);
14111418
rdesc[offs] = 0x19;
14121419
rdesc[offs + 1] = 0x00;
@@ -1490,6 +1497,9 @@ static const struct hid_device_id asus_devices[] = {
14901497
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
14911498
USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X),
14921499
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_ROG_ALLY_XPAD },
1500+
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1501+
USB_DEVICE_ID_ASUSTEK_XGM_2023),
1502+
},
14931503
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
14941504
USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD),
14951505
QUIRK_ROG_CLAYMORE_II_KEYBOARD },

drivers/hid/hid-cmedia.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int cmhid_raw_event(struct hid_device *hid, struct hid_report *report,
9999
{
100100
struct cmhid *cm = hid_get_drvdata(hid);
101101

102-
if (len != CM6533_JD_RAWEV_LEN)
102+
if (len != CM6533_JD_RAWEV_LEN || !(hid->claimed & HID_CLAIMED_INPUT))
103103
goto out;
104104
if (memcmp(data+CM6533_JD_SFX_OFFSET, ji_sfx, sizeof(ji_sfx)))
105105
goto out;

drivers/hid/hid-creative-sb0540.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int creative_sb0540_raw_event(struct hid_device *hid,
153153
u64 code, main_code;
154154
int key;
155155

156-
if (len != 6)
156+
if (len != 6 || !(hid->claimed & HID_CLAIMED_INPUT))
157157
return 0;
158158

159159
/* From daemons/hw_hiddev.c sb0540_rec() in lirc */

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
#define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X 0x1b4c
230230
#define USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD 0x196b
231231
#define USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD 0x1869
232+
#define USB_DEVICE_ID_ASUSTEK_XGM_2023 0x1a9a
232233

233234
#define USB_VENDOR_ID_ATEN 0x0557
234235
#define USB_DEVICE_ID_ATEN_UC100KM 0x2004

drivers/hid/hid-magicmouse.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,13 +990,11 @@ static const __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
990990
*/
991991
if ((is_usb_magicmouse2(hdev->vendor, hdev->product) ||
992992
is_usb_magictrackpad2(hdev->vendor, hdev->product)) &&
993-
*rsize == 83 && rdesc[46] == 0x84 && rdesc[58] == 0x85) {
993+
*rsize >= 83 && rdesc[46] == 0x84 && rdesc[58] == 0x85) {
994994
hid_info(hdev,
995995
"fixing up magicmouse battery report descriptor\n");
996996
*rsize = *rsize - 1;
997-
rdesc = kmemdup(rdesc + 1, *rsize, GFP_KERNEL);
998-
if (!rdesc)
999-
return NULL;
997+
rdesc = rdesc + 1;
1000998

1001999
rdesc[0] = 0x05;
10021000
rdesc[1] = 0x01;

drivers/hid/hid-mcp2221.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ static int mcp_i2c_smbus_read(struct mcp2221 *mcp,
353353
usleep_range(90, 100);
354354
retries++;
355355
} else {
356+
usleep_range(980, 1000);
357+
mcp_cancel_last_cmd(mcp);
356358
return ret;
357359
}
358360
} else {

drivers/hid/hid-multitouch.c

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ MODULE_LICENSE("GPL");
7777
#define MT_QUIRK_ORIENTATION_INVERT BIT(22)
7878
#define MT_QUIRK_APPLE_TOUCHBAR BIT(23)
7979
#define MT_QUIRK_YOGABOOK9I BIT(24)
80+
#define MT_QUIRK_KEEP_LATENCY_ON_CLOSE BIT(25)
8081

8182
#define MT_INPUTMODE_TOUCHSCREEN 0x02
8283
#define MT_INPUTMODE_TOUCHPAD 0x03
@@ -214,6 +215,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
214215
#define MT_CLS_WIN_8_DISABLE_WAKEUP 0x0016
215216
#define MT_CLS_WIN_8_NO_STICKY_FINGERS 0x0017
216217
#define MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU 0x0018
218+
#define MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE 0x0019
217219

218220
/* vendor specific classes */
219221
#define MT_CLS_3M 0x0101
@@ -233,6 +235,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
233235
#define MT_CLS_SMART_TECH 0x0113
234236
#define MT_CLS_APPLE_TOUCHBAR 0x0114
235237
#define MT_CLS_YOGABOOK9I 0x0115
238+
#define MT_CLS_EGALAX_P80H84 0x0116
236239
#define MT_CLS_SIS 0x0457
237240

238241
#define MT_DEFAULT_MAXCONTACT 10
@@ -334,6 +337,15 @@ static const struct mt_class mt_classes[] = {
334337
MT_QUIRK_CONTACT_CNT_ACCURATE |
335338
MT_QUIRK_WIN8_PTP_BUTTONS,
336339
.export_all_inputs = true },
340+
{ .name = MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE,
341+
.quirks = MT_QUIRK_ALWAYS_VALID |
342+
MT_QUIRK_IGNORE_DUPLICATES |
343+
MT_QUIRK_HOVERING |
344+
MT_QUIRK_CONTACT_CNT_ACCURATE |
345+
MT_QUIRK_STICKY_FINGERS |
346+
MT_QUIRK_WIN8_PTP_BUTTONS |
347+
MT_QUIRK_KEEP_LATENCY_ON_CLOSE,
348+
.export_all_inputs = true },
337349

338350
/*
339351
* vendor specific classes
@@ -438,6 +450,11 @@ static const struct mt_class mt_classes[] = {
438450
MT_QUIRK_YOGABOOK9I,
439451
.export_all_inputs = true
440452
},
453+
{ .name = MT_CLS_EGALAX_P80H84,
454+
.quirks = MT_QUIRK_ALWAYS_VALID |
455+
MT_QUIRK_IGNORE_DUPLICATES |
456+
MT_QUIRK_CONTACT_CNT_ACCURATE,
457+
},
441458
{ }
442459
};
443460

@@ -849,7 +866,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
849866
if ((cls->name == MT_CLS_WIN_8 ||
850867
cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT ||
851868
cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU ||
852-
cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP) &&
869+
cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP ||
870+
cls->name == MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE) &&
853871
(field->application == HID_DG_TOUCHPAD ||
854872
field->application == HID_DG_TOUCHSCREEN))
855873
app->quirks |= MT_QUIRK_CONFIDENCE;
@@ -1762,7 +1780,8 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
17621780
int ret;
17631781

17641782
if (td->is_haptic_touchpad && (td->mtclass.name == MT_CLS_WIN_8 ||
1765-
td->mtclass.name == MT_CLS_WIN_8_FORCE_MULTI_INPUT)) {
1783+
td->mtclass.name == MT_CLS_WIN_8_FORCE_MULTI_INPUT ||
1784+
td->mtclass.name == MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE)) {
17661785
if (hid_haptic_input_configured(hdev, td->haptic, hi) == 0)
17671786
td->is_haptic_touchpad = false;
17681787
} else {
@@ -2075,7 +2094,12 @@ static void mt_on_hid_hw_open(struct hid_device *hdev)
20752094

20762095
static void mt_on_hid_hw_close(struct hid_device *hdev)
20772096
{
2078-
mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_NONE);
2097+
struct mt_device *td = hid_get_drvdata(hdev);
2098+
2099+
if (td->mtclass.quirks & MT_QUIRK_KEEP_LATENCY_ON_CLOSE)
2100+
mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_NONE);
2101+
else
2102+
mt_set_modes(hdev, HID_LATENCY_HIGH, TOUCHPAD_REPORT_NONE);
20792103
}
20802104

20812105
/*
@@ -2215,8 +2239,9 @@ static const struct hid_device_id mt_devices[] = {
22152239
{ .driver_data = MT_CLS_EGALAX_SERIAL,
22162240
MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
22172241
USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C000) },
2218-
{ .driver_data = MT_CLS_EGALAX,
2219-
MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
2242+
{ .driver_data = MT_CLS_EGALAX_P80H84,
2243+
HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8,
2244+
USB_VENDOR_ID_DWAV,
22202245
USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C002) },
22212246

22222247
/* Elan devices */
@@ -2461,6 +2486,14 @@ static const struct hid_device_id mt_devices[] = {
24612486
MT_USB_DEVICE(USB_VENDOR_ID_UNITEC,
24622487
USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
24632488

2489+
/* Uniwill touchpads */
2490+
{ .driver_data = MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE,
2491+
HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
2492+
USB_VENDOR_ID_PIXART, 0x0255) },
2493+
{ .driver_data = MT_CLS_WIN_8_KEEP_LATENCY_ON_CLOSE,
2494+
HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
2495+
USB_VENDOR_ID_PIXART, 0x0274) },
2496+
24642497
/* VTL panels */
24652498
{ .driver_data = MT_CLS_VTL,
24662499
MT_USB_DEVICE(USB_VENDOR_ID_VTL,

drivers/hid/hid-zydacron.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int zc_raw_event(struct hid_device *hdev, struct hid_report *report,
114114
unsigned key;
115115
unsigned short index;
116116

117-
if (report->id == data[0]) {
117+
if (report->id == data[0] && (hdev->claimed & HID_CLAIMED_INPUT)) {
118118

119119
/* break keys */
120120
for (index = 0; index < 4; index++) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#define PCI_DEVICE_ID_INTEL_ISH_PTL_H 0xE345
4040
#define PCI_DEVICE_ID_INTEL_ISH_PTL_P 0xE445
4141
#define PCI_DEVICE_ID_INTEL_ISH_WCL 0x4D45
42+
#define PCI_DEVICE_ID_INTEL_ISH_NVL_H 0xD354
43+
#define PCI_DEVICE_ID_INTEL_ISH_NVL_S 0x6E78
4244

4345
#define REVISION_ID_CHT_A0 0x6
4446
#define REVISION_ID_CHT_Ax_SI 0x0

0 commit comments

Comments
 (0)