From: Dmitry Torokhov Date: Wed, 2 May 2012 07:13:36 +0000 (-0700) Subject: Input: evdev - properly access RCU-protected 'grab' data X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dba4258068f822b7dafc78c28fe9c99c551eca7e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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) 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);