kernel-ark/drivers/input/misc
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
..
88pm860x_onkey.c mfd: Add ability to wake the system for 88pm860x 2012-03-06 18:46:49 +01:00
ab8500-ponkey.c Input: ab8500-ponkey - add device tree support 2012-06-12 00:39:47 -07:00
ad714x-i2c.c Input: convert I2C drivers to use module_i2c_driver() 2012-03-16 23:06:19 -07:00
ad714x-spi.c Input: convert SPI drivers to use module_spi_driver() 2012-03-16 23:06:11 -07:00
ad714x.c Input: request threaded-only IRQs with IRQF_ONESHOT 2012-07-04 13:12:19 -07:00
ad714x.h Input: ad714x - read the interrupt status registers in a row 2011-08-22 09:59:26 -07:00
adxl34x-i2c.c Input: convert I2C drivers to use module_i2c_driver() 2012-03-16 23:06:19 -07:00
adxl34x-spi.c Input: convert SPI drivers to use module_spi_driver() 2012-03-16 23:06:11 -07:00
adxl34x.c Merge commit 'v3.2-rc3' into next 2011-11-29 01:51:07 -08:00
adxl34x.h
apanel.c
ati_remote2.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2012-01-10 10:55:52 -08:00
atlas_btns.c
bfin_rotary.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
bma150.c Input: convert I2C drivers to use module_i2c_driver() 2012-03-16 23:06:19 -07:00
cm109.c USB: input: cm109.c: fix up dev_* messages 2012-05-04 15:32:55 -07:00
cma3000_d0x_i2c.c Input: convert I2C drivers to use module_i2c_driver() 2012-03-16 23:06:19 -07:00
cma3000_d0x.c Input: cma3000-d0x - remove unneeded checks 2012-04-20 23:07:39 -07:00
cma3000_d0x.h
cobalt_btns.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
da9052_onkey.c Input: da9052 - fix memory leak in da9052_onkey_probe() 2012-04-11 22:15:04 -07:00
dm355evm_keys.c Input: request threaded-only IRQs with IRQF_ONESHOT 2012-07-04 13:12:19 -07:00
gp2ap002a00f.c Input: synaptics_usb - switch to module_usb_driver() 2012-03-16 23:06:34 -07:00
gpio_tilt_polled.c Input: add generic GPIO-tilt driver 2011-11-30 23:41:16 -08:00
hp_sdc_rtc.c
ixp4xx-beeper.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
Kconfig mfd: Convert twl6040 to i2c driver, and separate it from twl core 2012-04-16 16:45:34 +02:00
keyspan_remote.c USB: input: keyspan_remote.c: fix up dev_* messages 2012-05-04 15:32:58 -07:00
kxtj9.c Input: convert I2C drivers to use module_i2c_driver() 2012-03-16 23:06:19 -07:00
m68kspkr.c
Makefile Input: add driver support for MAX8997-haptic 2012-03-16 22:49:25 -07:00
max8925_onkey.c Input: max8925_onkey - avoid accessing input device too early 2012-03-06 11:03:30 -08:00
max8997_haptic.c Input: add driver support for MAX8997-haptic 2012-03-16 22:49:25 -07:00
mc13783-pwrbutton.c Input: mc13783-pwrbutton - convert to use module_platform_driver() 2011-12-12 00:02:51 -08:00
mma8450.c Input: convert I2C drivers to use module_i2c_driver() 2012-03-16 23:06:19 -07:00
mpu3050.c Input: mpu3050 - set IRQF_ONESHOT when requesting the interrupt 2012-05-02 00:22:45 -07:00
pcap_keys.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
pcf8574_keypad.c Input: convert I2C drivers to use module_i2c_driver() 2012-03-16 23:06:19 -07:00
pcf50633-input.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
pcspkr.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
pm8xxx-vibrator.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
pmic8xxx-pwrkey.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
powermate.c USB: input: powermate.c: fix up dev_* messages 2012-05-04 15:33:00 -07:00
pwm-beeper.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
rb532_button.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
rotary_encoder.c Input: rotary-encoder - add DT bindings 2012-08-21 22:29:51 -07:00
sgi_btns.c Input: misc - use macro module_platform_driver() 2011-11-30 23:41:42 -08:00
sparcspkr.c
twl4030-pwrbutton.c Input: twl4030-pwrbutton - report a wakeup_event on button press 2012-08-21 22:29:48 -07:00
twl4030-vibra.c Input: twl4030-vibra - really switch from #if to #ifdef 2012-03-12 22:18:54 -07:00
twl6040-vibra.c Input: twl6040-vibra - update for device tree support 2012-06-12 01:10:50 -07:00
uinput.c Input: uinput - fix race that can block nonblocking read 2012-08-21 22:29:53 -07:00
wistron_btns.c module_param: make bool parameters really bool (drivers & misc) 2012-01-13 09:32:20 +10:30
wm831x-on.c mfd: Convert wm831x to irq_domain 2012-05-20 17:27:07 +02:00
xen-kbdfront.c Xen: consolidate and simplify struct xenbus_driver instantiation 2012-01-04 17:01:17 -05:00
yealink.c USB: input: yealink.c: fix up dev_* messages 2012-05-04 15:33:01 -07:00
yealink.h