Hi,

there's a race in how open handles multiple openers.
You implement exclusive opening and wait for close
in case of further openers. However if there are more than one
waiter, only one of them must be allowed to proceed.

        Regards
                Oliver

You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


[EMAIL PROTECTED], 2004-03-19 17:07:43+01:00, [EMAIL PROTECTED]
  - fix race condition in open


 w9968cf.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)


diff -Nru a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c
--- a/drivers/usb/media/w9968cf.c       Fri Mar 19 17:08:38 2004
+++ b/drivers/usb/media/w9968cf.c       Fri Mar 19 17:08:38 2004
@@ -905,8 +905,7 @@
        spin_unlock(&cam->urb_lock);
 
        /* Wake up the user process */
-       if (waitqueue_active(&cam->wait_queue))
-               wake_up_interruptible(&cam->wait_queue);
+       wake_up_interruptible(&cam->wait_queue);
 }
 
 
@@ -2690,6 +2689,7 @@
                        up(&cam->dev_sem);
                        return -EWOULDBLOCK;
                }
+retry:
                up(&cam->dev_sem);
                err = wait_event_interruptible(cam->open, cam->disconnected ||
                                               (cam->users == 0));
@@ -2698,6 +2698,9 @@
                if (cam->disconnected)
                        return -ENODEV;
                down(&cam->dev_sem);
+               /*recheck - there may be several waiters */
+               if (cam->users)
+                       goto retry;
        }
 
        DBG(5, "Opening '%s', /dev/video%d ...",
@@ -2758,8 +2761,7 @@
        cam->users--;
        w9968cf_deallocate_memory(cam);
 
-       if (waitqueue_active(&cam->open))
-               wake_up_interruptible(&cam->open);
+       wake_up_interruptible(&cam->open);
 
        DBG(5, "Video device closed.")
        up(&cam->dev_sem);

===================================================================


This BitKeeper patch contains the following changesets:
1.1182
## Wrapped with gzip_uu ##


begin 664 bkpatch5842
M'XL(``8;6T```[54:VO40!3]G/[EMAIL PROTECTED]
MDEEG)ET+^?'.IEBM:%?%)B&9S'UPSKF'V8,[EMAIL PROTECTED]/?H"9[\%H96WANW?85
M=D&'_:IO`Z47+G:IE(N%2]5B>%<0?M"()FSJKC<^#V+BLBZD+9?@@J;P6"#N
M=^SM&@OO\N6KJ[?/+PF93.!T*;L%OD<+DPFQ2M_(IC)3:9>[EMAIL PROTECTED]:M#(H
M53O<IPZ<4N[NF*6"QLG`$AJE0\DJQF3$L*(\RI*(W,&;_H+'PU81%2RG*<T8
M&T3*>[EMAIL PROTECTED],91QH%%(1LAQ86M"TB,01906E\/O6<,3`I^0%_%\NIZ0$'^;U
M%]"R1"A55]6V5AW4':@U=N0-B%2D";GXKBCQ__(BA$I*3J#I2SEMZAEJ%=3V
MXT+CXM-0Z2UE$_9F%K98U3+<Y'[EMAIL PROTECTED]'(0C-+<<4A$/G"1T&0H,8UCQAEE
M5<PK?$2S7;W'`3EA4A$/(J)Y/#KGD:*MEYZ$!*GD#;;3KK<F&)>-FEO'Q.ZF
MP-W;[EMAIL PROTECTED]:/Q3\;3,1_8+`$_.B)#*:Q7&*YVKJJE,;-;`X&'0C9P$8Z
MPW4+L-*LS(^V&P?R#GR]&1]GHXO'9O,/KCS+:0:<G.?4Z42\C5SA=;^^KCN+
M6O=K6\\:W']6RM8_V:*\_MQCCP?'Y)PG.7<5&JV^+=QOZI05Q//"PV]$?;!+
MU`BMO(49/B#K\,-AZ++K.>R/S7MW3)H#M^,ME%4PMCTF9SQ-V!:>^_)=^+:B
:.63W!^*(PO3MA*=5FF4Q)5\!2G>\.8X%````
`
end


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to