@@ -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
0 commit comments