aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/evdev.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 4b2e10d5d641..9226b4d9118f 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -180,7 +180,10 @@ static int evdev_grab(struct evdev *evdev, struct evdev_client *client)
180 180
181static int evdev_ungrab(struct evdev *evdev, struct evdev_client *client) 181static int evdev_ungrab(struct evdev *evdev, struct evdev_client *client)
182{ 182{
183 if (evdev->grab != client) 183 struct evdev_client *grab = rcu_dereference_protected(evdev->grab,
184 lockdep_is_held(&evdev->mutex));
185
186 if (grab != client)
184 return -EINVAL; 187 return -EINVAL;
185 188
186 rcu_assign_pointer(evdev->grab, NULL); 189 rcu_assign_pointer(evdev->grab, NULL);
@@ -259,8 +262,7 @@ static int evdev_release(struct inode *inode, struct file *file)
259 struct evdev *evdev = client->evdev; 262 struct evdev *evdev = client->evdev;
260 263
261 mutex_lock(&evdev->mutex); 264 mutex_lock(&evdev->mutex);
262 if (evdev->grab == client) 265 evdev_ungrab(evdev, client);
263 evdev_ungrab(evdev, client);
264 mutex_unlock(&evdev->mutex); 266 mutex_unlock(&evdev->mutex);
265 267
266 evdev_detach_client(evdev, client); 268 evdev_detach_client(evdev, client);