aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-09-04 01:20:00 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-09-04 02:38:23 -0400
commiteb38f3a4f6e86f8bb10a3217ebd85ecc5d763aae (patch)
treed70b66eeaf28aa437edca9e2f09aa4500a02ff49
parent22c15e5e008297c90daa8657fea1a3f0e0675454 (diff)
Input: evdev - do not report errors form flush()
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 evdev_flush(). 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. Bugzilla: http://bugzilla.suse.com/show_bug.cgi?id=939834 Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/evdev.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 9d35499faca4..08d496411f75 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -290,19 +290,14 @@ static int evdev_flush(struct file *file, fl_owner_t id)
290{ 290{
291 struct evdev_client *client = file->private_data; 291 struct evdev_client *client = file->private_data;
292 struct evdev *evdev = client->evdev; 292 struct evdev *evdev = client->evdev;
293 int retval;
294 293
295 retval = mutex_lock_interruptible(&evdev->mutex); 294 mutex_lock(&evdev->mutex);
296 if (retval)
297 return retval;
298 295
299 if (!evdev->exist || client->revoked) 296 if (evdev->exist && !client->revoked)
300 retval = -ENODEV; 297 input_flush_device(&evdev->handle, file);
301 else
302 retval = input_flush_device(&evdev->handle, file);
303 298
304 mutex_unlock(&evdev->mutex); 299 mutex_unlock(&evdev->mutex);
305 return retval; 300 return 0;
306} 301}
307 302
308static void evdev_free(struct device *dev) 303static void evdev_free(struct device *dev)