Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: appletouch - fix potential race between resume and open

Take the input device's mutex in atp_resume() and atp_recover() to make
sure they are not racing with open and close methods, and use
input_device_enabled() helper to see if communication with the device
needs to be restarted after resume.

Link: https://patch.msgid.link/uuwucixxc2ckd6ul6yv5mdvkc3twytg4tg5a5vhfqg6m2qcodc@klaco6axglbm
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+4 -5
+4 -5
drivers/input/mouse/appletouch.c
··· 200 200 u8 *data; /* transferred data */ 201 201 struct input_dev *input; /* input dev */ 202 202 const struct atp_info *info; /* touchpad model */ 203 - bool open; 204 203 bool valid; /* are the samples valid? */ 205 204 bool size_detect_done; 206 205 bool overflow_warned; ··· 799 800 if (usb_submit_urb(dev->urb, GFP_KERNEL)) 800 801 return -EIO; 801 802 802 - dev->open = true; 803 803 return 0; 804 804 } 805 805 ··· 808 810 809 811 usb_kill_urb(dev->urb); 810 812 cancel_work_sync(&dev->work); 811 - dev->open = false; 812 813 } 813 814 814 815 static int atp_handle_geyser(struct atp *dev) ··· 960 963 if (error) 961 964 return error; 962 965 963 - if (dev->open && usb_submit_urb(dev->urb, GFP_KERNEL)) 966 + guard(mutex)(&dev->input->mutex); 967 + if (input_device_enabled(dev->input) && usb_submit_urb(dev->urb, GFP_KERNEL)) 964 968 return -EIO; 965 969 966 970 return 0; ··· 979 981 { 980 982 struct atp *dev = usb_get_intfdata(iface); 981 983 982 - if (dev->open && usb_submit_urb(dev->urb, GFP_KERNEL)) 984 + guard(mutex)(&dev->input->mutex); 985 + if (input_device_enabled(dev->input) && usb_submit_urb(dev->urb, GFP_KERNEL)) 983 986 return -EIO; 984 987 985 988 return 0;