--- y/drivers/input/input.c +++ n/drivers/input/input.c @@ -677,12 +677,13 @@ int input_open_device(struct input_handl if (retval) { dev->users--; handle->open--; + mutex_unlock(&dev->mutex); /* * Make sure we are not delivering any more events * through this handle */ synchronize_rcu(); - goto out; + return retval; } } @@ -722,6 +723,7 @@ EXPORT_SYMBOL(input_flush_device); void input_close_device(struct input_handle *handle) { struct input_dev *dev = handle->dev; + int sync = 0; mutex_lock(&dev->mutex); @@ -740,10 +742,12 @@ void input_close_device(struct input_han * completed and that no more input events are delivered * through this handle */ - synchronize_rcu(); + sync = 1; } mutex_unlock(&dev->mutex); + if (sync) + synchronize_rcu(); } EXPORT_SYMBOL(input_close_device);