]> git.hungrycats.org Git - linux/commitdiff
[PATCH] videobuf_waiton race fix
authorAndrew Morton <akpm@osdl.org>
Tue, 18 Nov 2003 16:14:33 +0000 (08:14 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Tue, 18 Nov 2003 16:14:33 +0000 (08:14 -0800)
There's a window in this function where a wakeup can get lost.

drivers/media/video/video-buf.c

index 0435a6050100e5c03256e34b53671b2037ae775a..5afc77fabfa1b29e79af4f3557a9c39725082f01 100644 (file)
@@ -320,14 +320,16 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
        DECLARE_WAITQUEUE(wait, current);
        
        add_wait_queue(&vb->done, &wait);
-       while (vb->state == STATE_ACTIVE ||
-              vb->state == STATE_QUEUED) {
+       while (vb->state == STATE_ACTIVE || vb->state == STATE_QUEUED) {
                if (non_blocking) {
                        retval = -EAGAIN;
                        break;
                }
-               current->state = intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
-               schedule();
+               set_current_state(intr ? TASK_INTERRUPTIBLE :
+                                       TASK_UNINTERRUPTIBLE);
+               if (vb->state == STATE_ACTIVE || vb->state == STATE_QUEUED)
+                       schedule();
+               set_current_state(TASK_RUNNING);
                if (intr && signal_pending(current)) {
                        dprintk(1,"buffer waiton: -EINTR\n");
                        retval = -EINTR;