summaryrefslogtreecommitdiff
path: root/drivers/input/evdev.c
diff options
context:
space:
mode:
authorDima Zavin <dima@android.com>2011-10-04 17:10:45 -0700
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:39:10 -0800
commit64eb4613f8242745822af408578e784abf64ecc7 (patch)
tree5863891bdd13bc0dc8c439b83f2de271c205cac3 /drivers/input/evdev.c
parentfc458f5194860f69b961deb0380e65b5006a2138 (diff)
input: evdev: do not block waiting for an event if fd is nonblock
If there is a full packet in the buffer, and we overflow that buffer right after checking for that condition, it would have been possible for us to block indefinitely (rather, until the next full packet) even if the file was marked as O_NONBLOCK. Change-Id: Icd0f59f8cc98392be4c4d13bd45b5cf94317eb5a Signed-off-by: Dima Zavin <dima@android.com>
Diffstat (limited to 'drivers/input/evdev.c')
-rw-r--r--drivers/input/evdev.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 10ae1c966a35..5c5f9db28075 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -405,14 +405,12 @@ static ssize_t evdev_read(struct file *file, char __user *buffer,
if (count < input_event_size())
return -EINVAL;
- if (client->packet_head == client->tail && evdev->exist &&
- (file->f_flags & O_NONBLOCK))
- return -EAGAIN;
-
- retval = wait_event_interruptible(evdev->wait,
- client->packet_head != client->tail || !evdev->exist);
- if (retval)
- return retval;
+ if (!(file->f_flags & O_NONBLOCK)) {
+ retval = wait_event_interruptible(evdev->wait,
+ client->packet_head != client->tail || !evdev->exist);
+ if (retval)
+ return retval;
+ }
if (!evdev->exist)
return -ENODEV;