@@ -76,17 +76,24 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
76
76
{
77
77
while (!kfifo_is_empty (fifo )) {
78
78
int size = kfifo_peek_len (fifo );
79
- u8 * buf = kzalloc ( size , GFP_KERNEL ) ;
79
+ u8 * buf ;
80
80
unsigned int count ;
81
81
int err ;
82
82
83
+ buf = kzalloc (size , GFP_KERNEL );
84
+ if (!buf ) {
85
+ kfifo_skip (fifo );
86
+ continue ;
87
+ }
88
+
83
89
count = kfifo_out (fifo , buf , size );
84
90
if (count != size ) {
85
91
// Hard to say what is the "right" action in this
86
92
// circumstance. Skipping the entry and continuing
87
93
// to flush seems reasonable enough, however.
88
94
hid_warn (hdev , "%s: removed fifo entry with unexpected size\n" ,
89
95
__func__ );
96
+ kfree (buf );
90
97
continue ;
91
98
}
92
99
err = hid_report_raw_event (hdev , HID_INPUT_REPORT , buf , size , false);
@@ -2058,14 +2065,18 @@ static int wacom_initialize_remotes(struct wacom *wacom)
2058
2065
2059
2066
remote -> remote_dir = kobject_create_and_add ("wacom_remote" ,
2060
2067
& wacom -> hdev -> dev .kobj );
2061
- if (!remote -> remote_dir )
2068
+ if (!remote -> remote_dir ) {
2069
+ kfifo_free (& remote -> remote_fifo );
2062
2070
return - ENOMEM ;
2071
+ }
2063
2072
2064
2073
error = sysfs_create_files (remote -> remote_dir , remote_unpair_attrs );
2065
2074
2066
2075
if (error ) {
2067
2076
hid_err (wacom -> hdev ,
2068
2077
"cannot create sysfs group err: %d\n" , error );
2078
+ kfifo_free (& remote -> remote_fifo );
2079
+ kobject_put (remote -> remote_dir );
2069
2080
return error ;
2070
2081
}
2071
2082
@@ -2378,6 +2389,8 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2378
2389
unsigned int connect_mask = HID_CONNECT_HIDRAW ;
2379
2390
2380
2391
features -> pktlen = wacom_compute_pktlen (hdev );
2392
+ if (!features -> pktlen )
2393
+ return - ENODEV ;
2381
2394
2382
2395
if (!devres_open_group (& hdev -> dev , wacom , GFP_KERNEL ))
2383
2396
return - ENOMEM ;
@@ -2909,11 +2922,16 @@ static void wacom_remove(struct hid_device *hdev)
2909
2922
hid_hw_stop (hdev );
2910
2923
2911
2924
cancel_delayed_work_sync (& wacom -> init_work );
2925
+ cancel_delayed_work_sync (& wacom -> aes_battery_work );
2912
2926
cancel_work_sync (& wacom -> wireless_work );
2913
2927
cancel_work_sync (& wacom -> battery_work );
2914
2928
cancel_work_sync (& wacom -> remote_work );
2915
2929
cancel_work_sync (& wacom -> mode_change_work );
2930
+ #ifdef WACOM_TIMER_DELETE_SYNC
2931
+ timer_delete_sync (& wacom -> idleprox_timer );
2932
+ #else
2916
2933
del_timer_sync (& wacom -> idleprox_timer );
2934
+ #endif
2917
2935
if (hdev -> bus == BUS_BLUETOOTH )
2918
2936
device_remove_file (& hdev -> dev , & dev_attr_speed );
2919
2937
0 commit comments