diff options
-rw-r--r-- | drivers/usb/usb-skeleton.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 5ffa3e246856..768fda9064e9 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c | |||
@@ -399,9 +399,16 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou | |||
399 | goto exit; | 399 | goto exit; |
400 | 400 | ||
401 | /* limit the number of URBs in flight to stop a user from using up all RAM */ | 401 | /* limit the number of URBs in flight to stop a user from using up all RAM */ |
402 | if (down_interruptible(&dev->limit_sem)) { | 402 | if (!file->f_flags & O_NONBLOCK) { |
403 | retval = -ERESTARTSYS; | 403 | if (down_interruptible(&dev->limit_sem)) { |
404 | goto exit; | 404 | retval = -ERESTARTSYS; |
405 | goto exit; | ||
406 | } | ||
407 | } else { | ||
408 | if (down_trylock(&dev->limit_sem)) { | ||
409 | retval = -EAGAIN; | ||
410 | goto exit; | ||
411 | } | ||
405 | } | 412 | } |
406 | 413 | ||
407 | spin_lock_irq(&dev->err_lock); | 414 | spin_lock_irq(&dev->err_lock); |