linux/drivers/input
Dmitry Torokhov 22ae19c6e3 Input: uinput - fix race that can block nonblocking read
Consider two threads calling read() on the same uinput-fd, both
non-blocking. Assume there is data-available so both will simultaneously
pass:
	udev->head == udev->tail

Then the first thread goes to sleep and the second one pops the message
from the queue. Now assume udev->head == udev->tail. If the first thread
wakes up it will call wait_event_*() and sleep in the waitq. This
effectively turns the non-blocking FD into a blocking one.

We fix this by attempting to fetch events from the queue first and only
if we fail to retrieve any events we either return -EAGAIN (in case of
non-blocing read) or wait until there are more events.

This also fixes incorrect return code (we were returning 0 instead of
 -EAGAIN for non-blocking reads) when an event is "stolen" by another
thread. Blocking reads will now continue to wait instead of returning 0
in this scenario.

Count of 0 continues to be a special case, as per spec: we will check for
device existence and whether there are events in the queue, but no events
will be actually retrieved.

Reported-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
2012-08-21 22:29:53 -07:00
..
gameport Input: use module_pci_driver 2012-04-21 23:48:58 -07:00
joystick Merge branch 'for-linus' to bring in change ensuring that drivers that 2012-07-07 16:07:48 -07:00
keyboard Input: gpio_keys_polled - convert to dt 2012-08-21 22:29:50 -07:00
misc Input: uinput - fix race that can block nonblocking read 2012-08-21 22:29:53 -07:00
mouse Input: synaptics - handle out of bounds values from the hardware 2012-07-24 23:55:15 -07:00
serio Input: serio_raw - signal EFAULT even if read/write partially succeeds 2012-05-02 00:21:13 -07:00
tablet Input: wacom - add support to Cintiq 22HD 2012-07-24 23:55:10 -07:00
touchscreen Input: add driver for FT5x06 based EDT displays 2012-07-24 23:55:03 -07:00
apm-power.c Input: random formatting fixes 2012-08-21 22:29:49 -07:00
evbug.c Input: use pr_fmt and pr_<level> 2010-11-30 23:10:26 -08:00
evdev.c Input: evdev - properly handle read/write with count 0 2012-05-02 00:23:58 -07:00
ff-core.c Input: random formatting fixes 2012-08-21 22:29:49 -07:00
ff-memless.c Input: random formatting fixes 2012-08-21 22:29:49 -07:00
input-compat.c compat: Use COMPAT_USE_64BIT_TIME in the input subsystem 2012-02-20 12:48:47 -08:00
input-compat.h compat: Use COMPAT_USE_64BIT_TIME in the input subsystem 2012-02-20 12:48:47 -08:00
input-mt.c Input: MT - fix null pointer warning 2012-06-04 16:33:34 +02:00
input-polldev.c Merge commit 'v3.2-rc3' into next 2011-11-29 01:51:07 -08:00
input.c Input: get rid of MATCH_BIT() macro 2012-08-21 22:29:52 -07:00
joydev.c Input: random formatting fixes 2012-08-21 22:29:49 -07:00
Kconfig Input: matrix-keymap - uninline and prepare for device tree support 2012-05-10 22:38:47 -07:00
Makefile Input: matrix-keymap - uninline and prepare for device tree support 2012-05-10 22:38:47 -07:00
matrix-keymap.c Input: matrix-keymap - fix building keymaps 2012-05-24 01:12:20 -07:00
mousedev.c Input: random formatting fixes 2012-08-21 22:29:49 -07:00
sparse-keymap.c Input: random formatting fixes 2012-08-21 22:29:49 -07:00