diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-05-02 00:13:36 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-05-02 00:23:14 -0700 |
commit | dba4258068f822b7dafc78c28fe9c99c551eca7e (patch) | |
tree | 0df5af1962e330399822c2d21f57a629f0b2d15c /drivers/input/evdev.c | |
parent | f31ad406693f114e57ad4651eb17deb68419c7cb (diff) | |
download | op-kernel-dev-dba4258068f822b7dafc78c28fe9c99c551eca7e.zip op-kernel-dev-dba4258068f822b7dafc78c28fe9c99c551eca7e.tar.gz |
Input: evdev - properly access RCU-protected 'grab' data
We should use rcu_dereference_protected() when checking if given client
is the one that grabbed the device. This fixes warnings produced by
sparse.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/evdev.c')
-rw-r--r-- | drivers/input/evdev.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 4b2e10d..9226b4d 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) 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); |