Commit 32265ac8 authored by Jiri Kosina's avatar Jiri Kosina Committed by Khalid Elmously

HID: hidraw, uhid: Always report EPOLLOUT

BugLink: https://bugs.launchpad.net/bugs/1860681

[ Upstream commit 9e635c28 ]

hidraw and uhid device nodes are always available for writing so we should
always report EPOLLOUT and EPOLLWRNORM bits, not only in the cases when
there is nothing to read.
Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Fixes: be54e746 ("HID: uhid: Fix returning EPOLLOUT from uhid_char_poll")
Fixes: 9f3b61dc ("HID: hidraw: Fix returning EPOLLOUT from hidraw_poll")
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent d15fccb2
......@@ -262,13 +262,14 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
static unsigned int hidraw_poll(struct file *file, poll_table *wait)
{
struct hidraw_list *list = file->private_data;
unsigned int mask = POLLOUT | POLLWRNORM; /* hidraw is always writable */
poll_wait(file, &list->hidraw->wait, wait);
if (list->head != list->tail)
return POLLIN | POLLRDNORM;
mask |= POLLIN | POLLRDNORM;
if (!list->hidraw->exist)
return POLLERR | POLLHUP;
return POLLOUT | POLLWRNORM;
mask |= POLLERR | POLLHUP;
return mask;
}
static int hidraw_open(struct inode *inode, struct file *file)
......
......@@ -769,13 +769,14 @@ static ssize_t uhid_char_write(struct file *file, const char __user *buffer,
static unsigned int uhid_char_poll(struct file *file, poll_table *wait)
{
struct uhid_device *uhid = file->private_data;
unsigned int mask = POLLOUT | POLLWRNORM; /* uhid is always writable */
poll_wait(file, &uhid->waitq, wait);
if (uhid->head != uhid->tail)
return POLLIN | POLLRDNORM;
mask |= POLLIN | POLLRDNORM;
return EPOLLOUT | EPOLLWRNORM;
return mask;
}
static const struct file_operations uhid_fops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment