Fix signal handling in read and write
authorIan Abbott <abbotti@mev.co.uk>
Tue, 1 Nov 2011 09:49:29 +0000 (09:49 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Tue, 1 Nov 2011 09:49:29 +0000 (09:49 +0000)
Follow bug-fix by Federico Vaga on the Linux "staging" version:

After sleeping on a wait queue, signal_pending(current) should be
checked (not before sleeping).

comedi/comedi_fops.c

index 0b29573b02cb0c7075cb28a671ddddb10c48b74a..210eb416f6a03210edfa9b1fee22c093fdddc1e5 100644 (file)
@@ -1682,11 +1682,11 @@ static ssize_t comedi_write(struct file *file, const char *buf, size_t nbytes,
                                retval = -EAGAIN;
                                break;
                        }
+                       schedule();
                        if (signal_pending(current)) {
                                retval = -ERESTARTSYS;
                                break;
                        }
-                       schedule();
                        if (!s->busy) {
                                break;
                        }
@@ -1784,11 +1784,11 @@ static ssize_t comedi_read(struct file *file, char *buf, size_t nbytes,
                                retval = -EAGAIN;
                                break;
                        }
+                       schedule();
                        if (signal_pending(current)) {
                                retval = -ERESTARTSYS;
                                break;
                        }
-                       schedule();
                        if (!s->busy) {
                                retval = 0;
                                break;