Commit 87abb6bbdbcfbced2ce0bcad68dd89ac3ff9464b
1 parent
a309cdc778
Exists in
master
and in
39 other branches
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>
Showing 1 changed file with 8 additions and 0 deletions Side-by-side Diff
drivers/macintosh/mac_hid.c
... | ... | @@ -23,6 +23,8 @@ |
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; |
... | ... | @@ -187,6 +189,10 @@ |
187 | 189 | int old_val = *valp; |
188 | 190 | int rc; |
189 | 191 | |
192 | + rc = mutex_lock_killable(&mac_hid_emumouse_mutex); | |
193 | + if (rc) | |
194 | + return rc; | |
195 | + | |
190 | 196 | rc = proc_dointvec(table, write, buffer, lenp, ppos); |
191 | 197 | |
192 | 198 | if (rc == 0 && write && *valp != old_val) { |
... | ... | @@ -201,6 +207,8 @@ |
201 | 207 | /* Restore the old value in case of error */ |
202 | 208 | if (rc) |
203 | 209 | *valp = old_val; |
210 | + | |
211 | + mutex_unlock(&mac_hid_emumouse_mutex); | |
204 | 212 | |
205 | 213 | return rc; |
206 | 214 | } |