Skip to content
Browse files

Input: evdev - do not report errors form flush()

commit eb38f3a upstream.

We've got bug reports showing the old systemd-logind (at least
system-210) aborting unexpectedly, and this turned out to be because
of an invalid error code from close() call to evdev devices.  close()
is supposed to return only either EINTR or EBADFD, while the device
returned ENODEV.  logind was overreacting to it and decided to kill
itself when an unexpected error code was received.  What a tragedy.

The bad error code comes from flush fops, and actually evdev_flush()
returns ENODEV when device is disconnected or client's access to it is
revoked. But in these cases the fact that flush did not actually happen is
not an error, but rather normal behavior. For non-disconnected devices
result of flush is also not that interesting as there is no potential of
data loss and even if it fails application has no way of handling the
error. Because of that we are better off always returning success from

Also returning EINTR from flush()/close() is discouraged (as it is not
clear how application should handle this error), so let's stop taking
evdev->mutex interruptibly.

Signed-off-by: Takashi Iwai <>
Signed-off-by: Dmitry Torokhov <>
Signed-off-by: Greg Kroah-Hartman <>
  • Loading branch information...
tiwai authored and gregkh committed Sep 4, 2015
1 parent f283a20 commit 37e7e6bf19f75255444a6a53d90a16d8c5e5a471
Showing with 4 additions and 9 deletions.
  1. +4 −9 drivers/input/evdev.c
@@ -290,19 +290,14 @@ static int evdev_flush(struct file *file, fl_owner_t id)
struct evdev_client *client = file->private_data;
struct evdev *evdev = client->evdev;
int retval;

retval = mutex_lock_interruptible(&evdev->mutex);
if (retval)
return retval;

if (!evdev->exist || client->revoked)
retval = -ENODEV;
retval = input_flush_device(&evdev->handle, file);
if (evdev->exist && !client->revoked)
input_flush_device(&evdev->handle, file);

return retval;
return 0;

static void evdev_free(struct device *dev)

0 comments on commit 37e7e6b

Please sign in to comment.
You can’t perform that action at this time.