Skip to content

Commit 231bc53

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: - memory leak fix in usbhid from Anirudh Rayabharam - additions for a few new recognized generic key IDs from Dmitry Torokhov - Asus T101HA and Dell K15A quirks from Hans de Goede - memory leak fix in amd_sfh from Basavaraj Natikar - Win8 compatibility and Stylus fixes in multitouch driver from Ahelenia Ziemiańska - NULL pointer dereference fix in hid-magicmouse from Johan Hovold - assorted other small fixes and device ID additions * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (33 commits) HID: asus: Cleanup Asus T101HA keyboard-dock handling HID: magicmouse: fix NULL-deref on disconnect HID: intel-ish-hid: ipc: Add Alder Lake device IDs HID: i2c-hid: fix format string mismatch HID: amd_sfh: Fix memory leak in amd_sfh_work HID: amd_sfh: Use devm_kzalloc() instead of kzalloc() HID: ft260: improve error handling of ft260_hid_feature_report_get() HID: magicmouse: fix crash when disconnecting Magic Trackpad 2 HID: gt683r: add missing MODULE_DEVICE_TABLE HID: pidff: fix error return code in hid_pidff_init() HID: logitech-hidpp: initialize level variable HID: multitouch: Disable event reporting on suspend on the Asus T101HA touchpad HID: core: Remove extraneous empty line before EXPORT_SYMBOL_GPL(hid_check_keys_pressed) HID: hid-sensor-custom: Process failure of sensor_hub_set_feature() HID: i2c-hid: Skip ELAN power-on command after reset HID: usbhid: fix info leak in hid_submit_ctrl HID: Add BUS_VIRTUAL to hid_connect logging HID: multitouch: set Stylus suffix for Stylus-application devices, too HID: multitouch: require Finger field to mark Win8 reports as MT HID: remove the unnecessary redefinition of a macro ...
2 parents 00151f5 + a94f66a commit 231bc53

28 files changed

+206
-70
lines changed

drivers/hid/Kconfig

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ menu "Special HID drivers"
9393
depends on HID
9494

9595
config HID_A4TECH
96-
tristate "A4 tech mice"
96+
tristate "A4TECH mice"
9797
depends on HID
9898
default !EXPERT
9999
help
100-
Support for A4 tech X5 and WOP-35 / Trust 450L mice.
100+
Support for some A4TECH mice with two scroll wheels.
101101

102102
config HID_ACCUTOUCH
103103
tristate "Accutouch touch device"
@@ -922,6 +922,21 @@ config HID_SAMSUNG
922922
help
923923
Support for Samsung InfraRed remote control or keyboards.
924924

925+
config HID_SEMITEK
926+
tristate "Semitek USB keyboards"
927+
depends on HID
928+
help
929+
Support for Semitek USB keyboards that are not fully compliant
930+
with the HID standard.
931+
932+
There are many variants, including:
933+
- GK61, GK64, GK68, GK84, GK96, etc.
934+
- SK61, SK64, SK68, SK84, SK96, etc.
935+
- Dierya DK61/DK66
936+
- Tronsmart TK09R
937+
- Woo-dy
938+
- X-Bows Nature/Knight
939+
925940
config HID_SONY
926941
tristate "Sony PS2/3/4 accessories"
927942
depends on USB_HID

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \
106106
obj-$(CONFIG_HID_RMI) += hid-rmi.o
107107
obj-$(CONFIG_HID_SAITEK) += hid-saitek.o
108108
obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
109+
obj-$(CONFIG_HID_SEMITEK) += hid-semitek.o
109110
obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o
110111
obj-$(CONFIG_HID_SONY) += hid-sony.o
111112
obj-$(CONFIG_HID_SPEEDLINK) += hid-speedlink.o

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ static void amd_sfh_work(struct work_struct *work)
8888
sensor_index = req_node->sensor_idx;
8989
report_id = req_node->report_id;
9090
node_type = req_node->report_type;
91+
kfree(req_node);
9192

9293
if (node_type == HID_FEATURE_REPORT) {
9394
report_size = get_feature_report(sensor_index, report_id,
@@ -142,7 +143,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
142143
int rc, i;
143144

144145
dev = &privdata->pdev->dev;
145-
cl_data = kzalloc(sizeof(*cl_data), GFP_KERNEL);
146+
cl_data = devm_kzalloc(dev, sizeof(*cl_data), GFP_KERNEL);
146147
if (!cl_data)
147148
return -ENOMEM;
148149

@@ -175,12 +176,12 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
175176
rc = -EINVAL;
176177
goto cleanup;
177178
}
178-
cl_data->feature_report[i] = kzalloc(feature_report_size, GFP_KERNEL);
179+
cl_data->feature_report[i] = devm_kzalloc(dev, feature_report_size, GFP_KERNEL);
179180
if (!cl_data->feature_report[i]) {
180181
rc = -ENOMEM;
181182
goto cleanup;
182183
}
183-
cl_data->input_report[i] = kzalloc(input_report_size, GFP_KERNEL);
184+
cl_data->input_report[i] = devm_kzalloc(dev, input_report_size, GFP_KERNEL);
184185
if (!cl_data->input_report[i]) {
185186
rc = -ENOMEM;
186187
goto cleanup;
@@ -189,7 +190,8 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
189190
info.sensor_idx = cl_idx;
190191
info.dma_address = cl_data->sensor_dma_addr[i];
191192

192-
cl_data->report_descr[i] = kzalloc(cl_data->report_descr_sz[i], GFP_KERNEL);
193+
cl_data->report_descr[i] =
194+
devm_kzalloc(dev, cl_data->report_descr_sz[i], GFP_KERNEL);
193195
if (!cl_data->report_descr[i]) {
194196
rc = -ENOMEM;
195197
goto cleanup;
@@ -214,11 +216,11 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
214216
cl_data->sensor_virt_addr[i],
215217
cl_data->sensor_dma_addr[i]);
216218
}
217-
kfree(cl_data->feature_report[i]);
218-
kfree(cl_data->input_report[i]);
219-
kfree(cl_data->report_descr[i]);
219+
devm_kfree(dev, cl_data->feature_report[i]);
220+
devm_kfree(dev, cl_data->input_report[i]);
221+
devm_kfree(dev, cl_data->report_descr[i]);
220222
}
221-
kfree(cl_data);
223+
devm_kfree(dev, cl_data);
222224
return rc;
223225
}
224226

@@ -241,6 +243,5 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata)
241243
cl_data->sensor_dma_addr[i]);
242244
}
243245
}
244-
kfree(cl_data);
245246
return 0;
246247
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ void amdtp_hid_remove(struct amdtp_cl_data *cli_data)
162162
int i;
163163

164164
for (i = 0; i < cli_data->num_hid_devices; ++i) {
165-
kfree(cli_data->feature_report[i]);
166-
kfree(cli_data->input_report[i]);
167-
kfree(cli_data->report_descr[i]);
168165
if (cli_data->hid_sensor_hubs[i]) {
169166
kfree(cli_data->hid_sensor_hubs[i]->driver_data);
170167
hid_destroy_device(cli_data->hid_sensor_hubs[i]);

drivers/hid/hid-a4tech.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ static const struct hid_device_id a4_devices[] = {
147147
.driver_data = A4_2WHEEL_MOUSE_HACK_B8 },
148148
{ HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649),
149149
.driver_data = A4_2WHEEL_MOUSE_HACK_B8 },
150+
{ HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_NB_95),
151+
.driver_data = A4_2WHEEL_MOUSE_HACK_B8 },
150152
{ }
151153
};
152154
MODULE_DEVICE_TABLE(hid, a4_devices);

drivers/hid/hid-asus.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
7979
#define QUIRK_T100_KEYBOARD BIT(6)
8080
#define QUIRK_T100CHI BIT(7)
8181
#define QUIRK_G752_KEYBOARD BIT(8)
82-
#define QUIRK_T101HA_DOCK BIT(9)
83-
#define QUIRK_T90CHI BIT(10)
84-
#define QUIRK_MEDION_E1239T BIT(11)
85-
#define QUIRK_ROG_NKEY_KEYBOARD BIT(12)
82+
#define QUIRK_T90CHI BIT(9)
83+
#define QUIRK_MEDION_E1239T BIT(10)
84+
#define QUIRK_ROG_NKEY_KEYBOARD BIT(11)
8685

8786
#define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
8887
QUIRK_NO_INIT_REPORTS | \
@@ -335,7 +334,7 @@ static int asus_raw_event(struct hid_device *hdev,
335334
if (drvdata->quirks & QUIRK_MEDION_E1239T)
336335
return asus_e1239t_event(drvdata, data, size);
337336

338-
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
337+
if (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) {
339338
/*
340339
* Skip these report ID, the device emits a continuous stream associated
341340
* with the AURA mode it is in which looks like an 'echo'.
@@ -355,6 +354,16 @@ static int asus_raw_event(struct hid_device *hdev,
355354
return -1;
356355
}
357356
}
357+
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
358+
/*
359+
* G713 and G733 send these codes on some keypresses, depending on
360+
* the key pressed it can trigger a shutdown event if not caught.
361+
*/
362+
if(data[0] == 0x02 && data[1] == 0x30) {
363+
return -1;
364+
}
365+
}
366+
358367
}
359368

360369
return 0;
@@ -1072,11 +1081,6 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
10721081
return ret;
10731082
}
10741083

1075-
/* use hid-multitouch for T101HA touchpad */
1076-
if (id->driver_data & QUIRK_T101HA_DOCK &&
1077-
hdev->collection->usage == HID_GD_MOUSE)
1078-
return -ENODEV;
1079-
10801084
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
10811085
if (ret) {
10821086
hid_err(hdev, "Asus hw start failed: %d\n", ret);
@@ -1230,15 +1234,19 @@ static const struct hid_device_id asus_devices[] = {
12301234
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
12311235
USB_DEVICE_ID_ASUSTEK_T100TAF_KEYBOARD),
12321236
QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
1233-
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1234-
USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD), QUIRK_T101HA_DOCK },
12351237
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_ASUS_AK1D) },
12361238
{ HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) },
12371239
{ HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) },
12381240
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
12391241
USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD), QUIRK_T100CHI },
12401242
{ HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE_MEDION_E1239T),
12411243
QUIRK_MEDION_E1239T },
1244+
/*
1245+
* Note bind to the HID_GROUP_GENERIC group, so that we only bind to the keyboard
1246+
* part, while letting hid-multitouch.c handle the touchpad.
1247+
*/
1248+
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
1249+
USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD) },
12421250
{ }
12431251
};
12441252
MODULE_DEVICE_TABLE(hid, asus_devices);

drivers/hid/hid-core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2005,6 +2005,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
20052005
case BUS_I2C:
20062006
bus = "I2C";
20072007
break;
2008+
case BUS_VIRTUAL:
2009+
bus = "VIRTUAL";
2010+
break;
20082011
default:
20092012
bus = "<UNKNOWN>";
20102013
}
@@ -2588,7 +2591,6 @@ int hid_check_keys_pressed(struct hid_device *hid)
25882591

25892592
return 0;
25902593
}
2591-
25922594
EXPORT_SYMBOL_GPL(hid_check_keys_pressed);
25932595

25942596
static int __init hid_init(void)

drivers/hid/hid-debug.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,9 @@ static const char *keys[KEY_MAX + 1] = {
930930
[KEY_APPSELECT] = "AppSelect",
931931
[KEY_SCREENSAVER] = "ScreenSaver",
932932
[KEY_VOICECOMMAND] = "VoiceCommand",
933+
[KEY_ASSISTANT] = "Assistant",
934+
[KEY_KBD_LAYOUT_NEXT] = "KbdLayoutNext",
935+
[KEY_EMOJI_PICKER] = "EmojiPicker",
933936
[KEY_BRIGHTNESS_MIN] = "BrightnessMin",
934937
[KEY_BRIGHTNESS_MAX] = "BrightnessMax",
935938
[KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",

drivers/hid/hid-ft260.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ struct ft260_i2c_write_request_report {
201201
u8 address; /* 7-bit I2C address */
202202
u8 flag; /* I2C transaction condition */
203203
u8 length; /* data payload length */
204-
u8 data[60]; /* data payload */
204+
u8 data[FT260_WR_DATA_MAX]; /* data payload */
205205
} __packed;
206206

207207
struct ft260_i2c_read_request_report {
@@ -249,7 +249,10 @@ static int ft260_hid_feature_report_get(struct hid_device *hdev,
249249

250250
ret = hid_hw_raw_request(hdev, report_id, buf, len, HID_FEATURE_REPORT,
251251
HID_REQ_GET_REPORT);
252-
memcpy(data, buf, len);
252+
if (likely(ret == len))
253+
memcpy(data, buf, len);
254+
else if (ret >= 0)
255+
ret = -EIO;
253256
kfree(buf);
254257
return ret;
255258
}
@@ -298,7 +301,7 @@ static int ft260_xfer_status(struct ft260_device *dev)
298301

299302
ret = ft260_hid_feature_report_get(hdev, FT260_I2C_STATUS,
300303
(u8 *)&report, sizeof(report));
301-
if (ret < 0) {
304+
if (unlikely(ret < 0)) {
302305
hid_err(hdev, "failed to retrieve status: %d\n", ret);
303306
return ret;
304307
}
@@ -429,6 +432,9 @@ static int ft260_smbus_write(struct ft260_device *dev, u8 addr, u8 cmd,
429432
struct ft260_i2c_write_request_report *rep =
430433
(struct ft260_i2c_write_request_report *)dev->write_buf;
431434

435+
if (data_len >= sizeof(rep->data))
436+
return -EINVAL;
437+
432438
rep->address = addr;
433439
rep->data[0] = cmd;
434440
rep->length = data_len + 1;
@@ -721,10 +727,9 @@ static int ft260_get_system_config(struct hid_device *hdev,
721727

722728
ret = ft260_hid_feature_report_get(hdev, FT260_SYSTEM_SETTINGS,
723729
(u8 *)cfg, len);
724-
if (ret != len) {
730+
if (ret < 0) {
725731
hid_err(hdev, "failed to retrieve system status\n");
726-
if (ret >= 0)
727-
return -EIO;
732+
return ret;
728733
}
729734
return 0;
730735
}
@@ -777,8 +782,8 @@ static int ft260_byte_show(struct hid_device *hdev, int id, u8 *cfg, int len,
777782
int ret;
778783

779784
ret = ft260_hid_feature_report_get(hdev, id, cfg, len);
780-
if (ret != len && ret >= 0)
781-
return -EIO;
785+
if (ret < 0)
786+
return ret;
782787

783788
return scnprintf(buf, PAGE_SIZE, "%hi\n", *field);
784789
}
@@ -789,8 +794,8 @@ static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,
789794
int ret;
790795

791796
ret = ft260_hid_feature_report_get(hdev, id, cfg, len);
792-
if (ret != len && ret >= 0)
793-
return -EIO;
797+
if (ret < 0)
798+
return ret;
794799

795800
return scnprintf(buf, PAGE_SIZE, "%hi\n", le16_to_cpu(*field));
796801
}
@@ -941,10 +946,8 @@ static int ft260_probe(struct hid_device *hdev, const struct hid_device_id *id)
941946

942947
ret = ft260_hid_feature_report_get(hdev, FT260_CHIP_VERSION,
943948
(u8 *)&version, sizeof(version));
944-
if (ret != sizeof(version)) {
949+
if (ret < 0) {
945950
hid_err(hdev, "failed to retrieve chip version\n");
946-
if (ret >= 0)
947-
ret = -EIO;
948951
goto err_hid_close;
949952
}
950953

drivers/hid/hid-gt683r.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static const struct hid_device_id gt683r_led_id[] = {
5454
{ HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) },
5555
{ }
5656
};
57+
MODULE_DEVICE_TABLE(hid, gt683r_led_id);
5758

5859
static void gt683r_brightness_set(struct led_classdev *led_cdev,
5960
enum led_brightness brightness)

0 commit comments

Comments
 (0)