diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 88ba0b6488051840f81d85e62542f108207cee38..190592ad092160fa1d96e541fb983701920e8c95 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) {