diff options
Diffstat (limited to 'drivers/char/virtio_console.c')
| -rw-r--r-- | drivers/char/virtio_console.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 942a9826bd23..c810481a5bc2 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
| @@ -596,6 +596,10 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf, | |||
| 596 | ssize_t ret; | 596 | ssize_t ret; |
| 597 | bool nonblock; | 597 | bool nonblock; |
| 598 | 598 | ||
| 599 | /* Userspace could be out to fool us */ | ||
| 600 | if (!count) | ||
| 601 | return 0; | ||
| 602 | |||
| 599 | port = filp->private_data; | 603 | port = filp->private_data; |
| 600 | 604 | ||
| 601 | nonblock = filp->f_flags & O_NONBLOCK; | 605 | nonblock = filp->f_flags & O_NONBLOCK; |
| @@ -642,7 +646,7 @@ static unsigned int port_fops_poll(struct file *filp, poll_table *wait) | |||
| 642 | poll_wait(filp, &port->waitqueue, wait); | 646 | poll_wait(filp, &port->waitqueue, wait); |
| 643 | 647 | ||
| 644 | ret = 0; | 648 | ret = 0; |
| 645 | if (port->inbuf) | 649 | if (!will_read_block(port)) |
| 646 | ret |= POLLIN | POLLRDNORM; | 650 | ret |= POLLIN | POLLRDNORM; |
| 647 | if (!will_write_block(port)) | 651 | if (!will_write_block(port)) |
| 648 | ret |= POLLOUT; | 652 | ret |= POLLOUT; |
