|
@@ -180,7 +180,10 @@ static int evdev_grab(struct evdev *evdev, struct evdev_client *client)
|
|
|
|
|
|
static int evdev_ungrab(struct evdev *evdev, struct evdev_client *client)
|
|
|
{
|
|
|
- if (evdev->grab != client)
|
|
|
+ struct evdev_client *grab = rcu_dereference_protected(evdev->grab,
|
|
|
+ lockdep_is_held(&evdev->mutex));
|
|
|
+
|
|
|
+ if (grab != client)
|
|
|
return -EINVAL;
|
|
|
|
|
|
rcu_assign_pointer(evdev->grab, NULL);
|
|
@@ -259,8 +262,7 @@ static int evdev_release(struct inode *inode, struct file *file)
|
|
|
struct evdev *evdev = client->evdev;
|
|
|
|
|
|
mutex_lock(&evdev->mutex);
|
|
|
- if (evdev->grab == client)
|
|
|
- evdev_ungrab(evdev, client);
|
|
|
+ evdev_ungrab(evdev, client);
|
|
|
mutex_unlock(&evdev->mutex);
|
|
|
|
|
|
evdev_detach_client(evdev, client);
|