Skip to content

Commit 9e635c2

Browse files
author
Jiri Kosina
committed
HID: hidraw, uhid: Always report EPOLLOUT
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: Linus Torvalds <[email protected]> Fixes: be54e74 ("HID: uhid: Fix returning EPOLLOUT from uhid_char_poll") Fixes: 9f3b61d ("HID: hidraw: Fix returning EPOLLOUT from hidraw_poll") Signed-off-by: Jiri Kosina <[email protected]>
1 parent 20eee6e commit 9e635c2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/hid/hidraw.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,14 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
249249
static __poll_t hidraw_poll(struct file *file, poll_table *wait)
250250
{
251251
struct hidraw_list *list = file->private_data;
252+
__poll_t mask = EPOLLOUT | EPOLLWRNORM; /* hidraw is always writable */
252253

253254
poll_wait(file, &list->hidraw->wait, wait);
254255
if (list->head != list->tail)
255-
return EPOLLIN | EPOLLRDNORM;
256+
mask |= EPOLLIN | EPOLLRDNORM;
256257
if (!list->hidraw->exist)
257-
return EPOLLERR | EPOLLHUP;
258-
return EPOLLOUT | EPOLLWRNORM;
258+
mask |= EPOLLERR | EPOLLHUP;
259+
return mask;
259260
}
260261

261262
static int hidraw_open(struct inode *inode, struct file *file)

drivers/hid/uhid.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,13 +766,14 @@ static ssize_t uhid_char_write(struct file *file, const char __user *buffer,
766766
static __poll_t uhid_char_poll(struct file *file, poll_table *wait)
767767
{
768768
struct uhid_device *uhid = file->private_data;
769+
__poll_t mask = EPOLLOUT | EPOLLWRNORM; /* uhid is always writable */
769770

770771
poll_wait(file, &uhid->waitq, wait);
771772

772773
if (uhid->head != uhid->tail)
773-
return EPOLLIN | EPOLLRDNORM;
774+
mask |= EPOLLIN | EPOLLRDNORM;
774775

775-
return EPOLLOUT | EPOLLWRNORM;
776+
return mask;
776777
}
777778

778779
static const struct file_operations uhid_fops = {

0 commit comments

Comments
 (0)