提交 79819986 编写于 作者: O Oliver Neukum 提交者: Greg Kroah-Hartman

USB: make usb-skeleton honor O_NONBLOCK in write path

usb:usb-skeleton: honor O_NONBLOCK in write path

nonblocking writes are allowed by using down_trylock if necessary
to reserve an URB
Signed-off-by: NOliver Neukum <oliver@neukum.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 e7389cc9
...@@ -399,10 +399,17 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou ...@@ -399,10 +399,17 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
goto exit; goto exit;
/* limit the number of URBs in flight to stop a user from using up all RAM */ /* limit the number of URBs in flight to stop a user from using up all RAM */
if (!file->f_flags & O_NONBLOCK) {
if (down_interruptible(&dev->limit_sem)) { if (down_interruptible(&dev->limit_sem)) {
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
goto exit; goto exit;
} }
} else {
if (down_trylock(&dev->limit_sem)) {
retval = -EAGAIN;
goto exit;
}
}
spin_lock_irq(&dev->err_lock); spin_lock_irq(&dev->err_lock);
if ((retval = dev->errors) < 0) { if ((retval = dev->errors) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册