Skip to content

Commit fe661d0

Browse files
committed
Merge tag 'hid-for-linus-2025051501' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID fixes from Benjamin Tissoires: - fix a few potential memory leaks in the wacom driver (Qasim Ijaz) - AMD SFH fixes when there is only one SRA sensor (Mario Limonciello) - HID-BPF dispatch UAF fix that happens on removal of the Logitech DJ receiver (Rong Zhang) - various minor fixes and usual device ID additions * tag 'hid-for-linus-2025051501' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: HID: bpf: abort dispatch if device destroyed HID: quirks: Add ADATA XPG alpha wireless mouse support HID: hid-steam: Remove the unused variable connected HID: amd_sfh: Avoid clearing reports for SRA sensor HID: amd_sfh: Fix SRA sensor when it's the only sensor HID: wacom: fix shift OOB in kfifo allocation for zero pktlen HID: uclogic: Add NULL check in uclogic_input_configured() HID: wacom: fix memory leak on size mismatch in wacom_wac_queue_flush() HID: wacom: handle kzalloc() allocation failure in wacom_wac_queue_flush() HID: thrustmaster: fix memory leak in thrustmaster_interrupts() HID: hid-appletb-kbd: Fix wrong date and kernel version in sysfs interface docs HID: bpf: fix BTN_STYLUS for the XP Pen ACK05 remote
2 parents ef93565 + 578e1b9 commit fe661d0

File tree

10 files changed

+41
-12
lines changed

10 files changed

+41
-12
lines changed

Documentation/ABI/testing/sysfs-driver-hid-appletb-kbd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
What: /sys/bus/hid/drivers/hid-appletb-kbd/<dev>/mode
2-
Date: September, 2023
3-
KernelVersion: 6.5
2+
Date: March, 2025
3+
KernelVersion: 6.15
44
Contact: linux-input@vger.kernel.org
55
Description:
66
The set of keys displayed on the Touch Bar.

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ static int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata)
8383
case ALS_IDX:
8484
privdata->dev_en.is_als_present = false;
8585
break;
86+
case SRA_IDX:
87+
privdata->dev_en.is_sra_present = false;
88+
break;
8689
}
8790

8891
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
@@ -134,9 +137,6 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
134137
for (i = 0; i < cl_data->num_hid_devices; i++) {
135138
cl_data->sensor_sts[i] = SENSOR_DISABLED;
136139

137-
if (cl_data->num_hid_devices == 1 && cl_data->sensor_idx[0] == SRA_IDX)
138-
break;
139-
140140
if (cl_data->sensor_idx[i] == SRA_IDX) {
141141
info.sensor_idx = cl_data->sensor_idx[i];
142142
writel(0, privdata->mmio + amd_get_p2c_val(privdata, 0));
@@ -145,8 +145,10 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
145145
(privdata, cl_data->sensor_idx[i], ENABLE_SENSOR);
146146

147147
cl_data->sensor_sts[i] = (status == 0) ? SENSOR_ENABLED : SENSOR_DISABLED;
148-
if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
148+
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
149+
cl_data->is_any_sensor_enabled = true;
149150
privdata->dev_en.is_sra_present = true;
151+
}
150152
continue;
151153
}
152154

@@ -238,6 +240,8 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
238240
cleanup:
239241
amd_sfh_hid_client_deinit(privdata);
240242
for (i = 0; i < cl_data->num_hid_devices; i++) {
243+
if (cl_data->sensor_idx[i] == SRA_IDX)
244+
continue;
241245
devm_kfree(dev, cl_data->feature_report[i]);
242246
devm_kfree(dev, in_data->input_report[i]);
243247
devm_kfree(dev, cl_data->report_descr[i]);

drivers/hid/bpf/hid_bpf_dispatch.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ dispatch_hid_bpf_device_event(struct hid_device *hdev, enum hid_report_type type
3838
struct hid_bpf_ops *e;
3939
int ret;
4040

41+
if (unlikely(hdev->bpf.destroyed))
42+
return ERR_PTR(-ENODEV);
43+
4144
if (type >= HID_REPORT_TYPES)
4245
return ERR_PTR(-EINVAL);
4346

@@ -93,6 +96,9 @@ int dispatch_hid_bpf_raw_requests(struct hid_device *hdev,
9396
struct hid_bpf_ops *e;
9497
int ret, idx;
9598

99+
if (unlikely(hdev->bpf.destroyed))
100+
return -ENODEV;
101+
96102
if (rtype >= HID_REPORT_TYPES)
97103
return -EINVAL;
98104

@@ -130,6 +136,9 @@ int dispatch_hid_bpf_output_report(struct hid_device *hdev,
130136
struct hid_bpf_ops *e;
131137
int ret, idx;
132138

139+
if (unlikely(hdev->bpf.destroyed))
140+
return -ENODEV;
141+
133142
idx = srcu_read_lock(&hdev->bpf.srcu);
134143
list_for_each_entry_srcu(e, &hdev->bpf.prog_list, list,
135144
srcu_read_lock_held(&hdev->bpf.srcu)) {

drivers/hid/bpf/progs/XPPen__ACK05.bpf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static const __u8 fixed_rdesc_vendor[] = {
157157
ReportCount(5) // padding
158158
Input(Const)
159159
// Byte 4 in report - just exists so we get to be a tablet pad
160+
UsagePage_Digitizers
160161
Usage_Dig_BarrelSwitch // BTN_STYLUS
161162
ReportCount(1)
162163
ReportSize(1)

drivers/hid/hid-ids.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#define USB_VENDOR_ID_ACTIONSTAR 0x2101
4242
#define USB_DEVICE_ID_ACTIONSTAR_1011 0x1011
4343

44+
#define USB_VENDOR_ID_ADATA_XPG 0x125f
45+
#define USB_VENDOR_ID_ADATA_XPG_WL_GAMING_MOUSE 0x7505
46+
#define USB_VENDOR_ID_ADATA_XPG_WL_GAMING_MOUSE_DONGLE 0x7506
47+
4448
#define USB_VENDOR_ID_ADS_TECH 0x06e1
4549
#define USB_DEVICE_ID_ADS_TECH_RADIO_SI470X 0xa155
4650

drivers/hid/hid-quirks.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
static const struct hid_device_id hid_quirks[] = {
2828
{ HID_USB_DEVICE(USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD), HID_QUIRK_BADPAD },
2929
{ HID_USB_DEVICE(USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR), HID_QUIRK_BADPAD },
30+
{ HID_USB_DEVICE(USB_VENDOR_ID_ADATA_XPG, USB_VENDOR_ID_ADATA_XPG_WL_GAMING_MOUSE), HID_QUIRK_ALWAYS_POLL },
31+
{ HID_USB_DEVICE(USB_VENDOR_ID_ADATA_XPG, USB_VENDOR_ID_ADATA_XPG_WL_GAMING_MOUSE_DONGLE), HID_QUIRK_ALWAYS_POLL },
3032
{ HID_USB_DEVICE(USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016), HID_QUIRK_FULLSPEED_INTERVAL },
3133
{ HID_USB_DEVICE(USB_VENDOR_ID_AIREN, USB_DEVICE_ID_AIREN_SLIMPLUS), HID_QUIRK_NOGET },
3234
{ HID_USB_DEVICE(USB_VENDOR_ID_AKAI_09E8, USB_DEVICE_ID_AKAI_09E8_MIDIMIX), HID_QUIRK_NO_INIT_REPORTS },

drivers/hid/hid-steam.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,11 +1150,9 @@ static void steam_client_ll_close(struct hid_device *hdev)
11501150
struct steam_device *steam = hdev->driver_data;
11511151

11521152
unsigned long flags;
1153-
bool connected;
11541153

11551154
spin_lock_irqsave(&steam->lock, flags);
11561155
steam->client_opened--;
1157-
connected = steam->connected && !steam->client_opened;
11581156
spin_unlock_irqrestore(&steam->lock, flags);
11591157

11601158
schedule_work(&steam->unregister_work);

drivers/hid/hid-thrustmaster.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ static void thrustmaster_interrupts(struct hid_device *hdev)
174174
u8 ep_addr[2] = {b_ep, 0};
175175

176176
if (!usb_check_int_endpoints(usbif, ep_addr)) {
177+
kfree(send_buf);
177178
hid_err(hdev, "Unexpected non-int endpoint\n");
178179
return;
179180
}

drivers/hid/hid-uclogic-core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ static int uclogic_input_configured(struct hid_device *hdev,
142142
suffix = "System Control";
143143
break;
144144
}
145-
}
146-
147-
if (suffix)
145+
} else {
148146
hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
149147
"%s %s", hdev->name, suffix);
148+
if (!hi->input->name)
149+
return -ENOMEM;
150+
}
150151

151152
return 0;
152153
}

drivers/hid/wacom_sys.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,24 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
7070
{
7171
while (!kfifo_is_empty(fifo)) {
7272
int size = kfifo_peek_len(fifo);
73-
u8 *buf = kzalloc(size, GFP_KERNEL);
73+
u8 *buf;
7474
unsigned int count;
7575
int err;
7676

77+
buf = kzalloc(size, GFP_KERNEL);
78+
if (!buf) {
79+
kfifo_skip(fifo);
80+
continue;
81+
}
82+
7783
count = kfifo_out(fifo, buf, size);
7884
if (count != size) {
7985
// Hard to say what is the "right" action in this
8086
// circumstance. Skipping the entry and continuing
8187
// to flush seems reasonable enough, however.
8288
hid_warn(hdev, "%s: removed fifo entry with unexpected size\n",
8389
__func__);
90+
kfree(buf);
8491
continue;
8592
}
8693
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, false);
@@ -2361,6 +2368,8 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
23612368
unsigned int connect_mask = HID_CONNECT_HIDRAW;
23622369

23632370
features->pktlen = wacom_compute_pktlen(hdev);
2371+
if (!features->pktlen)
2372+
return -ENODEV;
23642373

23652374
if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL))
23662375
return -ENOMEM;

0 commit comments

Comments
 (0)