Skip to content

Commit

Permalink
Input: evdev - properly access RCU-protected 'grab' data
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dmitry Torokhov committed May 2, 2012
1 parent f31ad40 commit dba4258
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dba4258

Please sign in to comment.