diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 88ba0b648805..190592ad0921 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2478,8 +2478,12 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, } async = s->async; - if (!s->busy || !nbytes) + if (!nbytes) goto out; + if (!s->busy) { + retval = -EINVAL; + goto out; + } if (s->busy != file) { retval = -EACCES; goto out; @@ -2517,6 +2521,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, break; } if (!s->busy) { + retval = -EINVAL; break; } if (s->busy != file) {