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

Input: mac mouse emulation - add locking

We need to add appropriate locking when toggling mac mouse emulation
on and off to ensure that input device and handler are in consistent
state.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

+8
+8
drivers/macintosh/mac_hid.c
··· 23 23 24 24 static struct input_dev *mac_hid_emumouse_dev; 25 25 26 + static DEFINE_MUTEX(mac_hid_emumouse_mutex); 27 + 26 28 static int mac_hid_create_emumouse(void) 27 29 { 28 30 static struct lock_class_key mac_hid_emumouse_dev_event_class; ··· 189 187 int old_val = *valp; 190 188 int rc; 191 189 190 + rc = mutex_lock_killable(&mac_hid_emumouse_mutex); 191 + if (rc) 192 + return rc; 193 + 192 194 rc = proc_dointvec(table, write, buffer, lenp, ppos); 193 195 194 196 if (rc == 0 && write && *valp != old_val) { ··· 207 201 /* Restore the old value in case of error */ 208 202 if (rc) 209 203 *valp = old_val; 204 + 205 + mutex_unlock(&mac_hid_emumouse_mutex); 210 206 211 207 return rc; 212 208 }