Skip to content

Commit c6b7540

Browse files
authored
Merge pull request #463 from Joshua-Dickens/master
Import multiple upstream patches
2 parents 5c2ebb1 + 363ed5e commit c6b7540

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

4.18/wacom_sys.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,24 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
7676
{
7777
while (!kfifo_is_empty(fifo)) {
7878
int size = kfifo_peek_len(fifo);
79-
u8 *buf = kzalloc(size, GFP_KERNEL);
79+
u8 *buf;
8080
unsigned int count;
8181
int err;
8282

83+
buf = kzalloc(size, GFP_KERNEL);
84+
if (!buf) {
85+
kfifo_skip(fifo);
86+
continue;
87+
}
88+
8389
count = kfifo_out(fifo, buf, size);
8490
if (count != size) {
8591
// Hard to say what is the "right" action in this
8692
// circumstance. Skipping the entry and continuing
8793
// to flush seems reasonable enough, however.
8894
hid_warn(hdev, "%s: removed fifo entry with unexpected size\n",
8995
__func__);
96+
kfree(buf);
9097
continue;
9198
}
9299
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, false);
@@ -2058,14 +2065,18 @@ static int wacom_initialize_remotes(struct wacom *wacom)
20582065

20592066
remote->remote_dir = kobject_create_and_add("wacom_remote",
20602067
&wacom->hdev->dev.kobj);
2061-
if (!remote->remote_dir)
2068+
if (!remote->remote_dir) {
2069+
kfifo_free(&remote->remote_fifo);
20622070
return -ENOMEM;
2071+
}
20632072

20642073
error = sysfs_create_files(remote->remote_dir, remote_unpair_attrs);
20652074

20662075
if (error) {
20672076
hid_err(wacom->hdev,
20682077
"cannot create sysfs group err: %d\n", error);
2078+
kfifo_free(&remote->remote_fifo);
2079+
kobject_put(remote->remote_dir);
20692080
return error;
20702081
}
20712082

@@ -2378,6 +2389,8 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
23782389
unsigned int connect_mask = HID_CONNECT_HIDRAW;
23792390

23802391
features->pktlen = wacom_compute_pktlen(hdev);
2392+
if (!features->pktlen)
2393+
return -ENODEV;
23812394

23822395
if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL))
23832396
return -ENOMEM;
@@ -2909,11 +2922,16 @@ static void wacom_remove(struct hid_device *hdev)
29092922
hid_hw_stop(hdev);
29102923

29112924
cancel_delayed_work_sync(&wacom->init_work);
2925+
cancel_delayed_work_sync(&wacom->aes_battery_work);
29122926
cancel_work_sync(&wacom->wireless_work);
29132927
cancel_work_sync(&wacom->battery_work);
29142928
cancel_work_sync(&wacom->remote_work);
29152929
cancel_work_sync(&wacom->mode_change_work);
2930+
#ifdef WACOM_TIMER_DELETE_SYNC
2931+
timer_delete_sync(&wacom->idleprox_timer);
2932+
#else
29162933
del_timer_sync(&wacom->idleprox_timer);
2934+
#endif
29172935
if (hdev->bus == BUS_BLUETOOTH)
29182936
device_remove_file(&hdev->dev, &dev_attr_speed);
29192937

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,22 @@ WACOM_LINUX_TRY_COMPILE([
287287
AC_MSG_RESULT([no])
288288
])
289289

290+
dnl Check if del_timer_sync has been renamed to timer_delete_sync or
291+
dnl not. This is the case in Linux 6.1.84 and later.
292+
AC_MSG_CHECKING(timer_delete_sync)
293+
WACOM_LINUX_TRY_COMPILE([
294+
#include <linux/timer.h>
295+
bool timer_delete_sync(struct timer_list *timer) { return true; }
296+
],[
297+
],[
298+
HAVE_TIMER_DELETE_SYNC=no
299+
AC_MSG_RESULT([no])
300+
],[
301+
HAVE_TIMER_DELETE_SYNC=yes
302+
AC_MSG_RESULT([yes])
303+
AC_DEFINE([WACOM_TIMER_DELETE_SYNC], [], [kernel defines timer_delete_sync from v6.1.84+])
304+
])
305+
290306

291307

292308
dnl Check which version of the driver we should compile

0 commit comments

Comments
 (0)