diff --git a/drivers/input/input.c b/drivers/input/input.c index 53a0ddee78724221e1134310eca5574dde3ce7ec..f1be1a77edf31c9236ee96baa3a74e13a7bbd994 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -534,8 +534,11 @@ EXPORT_SYMBOL(input_grab_device); static void __input_release_device(struct input_handle *handle) { struct input_dev *dev = handle->dev; + struct input_handle *grabber; - if (dev->grab == handle) { + grabber = rcu_dereference_protected(dev->grab, + lockdep_is_held(&dev->mutex)); + if (grabber == handle) { rcu_assign_pointer(dev->grab, NULL); /* Make sure input_pass_event() notices that grab is gone */ synchronize_rcu();