ChangeSet 1.1807.48.46, 2004/08/06 13:55:57-07:00, [EMAIL PROTECTED]

[PATCH] USB: usbfs: drop the device semaphore in proc_bulk and proc_control

usb_control_msg and usb_bulk_msg may sleep for a long time, so drop the per device
semaphore before calling them.  This fixes OSDL bug 3108.  Dropping the semaphore
is racy, but (1) the race is fairly harmless, (2) it can be occur elsewhere as an 
inevitable
consequence of the current usbfs api, this just makes it fractionally more likely.

Signed-off-by: Duncan Sands <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/core/devio.c |    8 ++++++++
 1 files changed, 8 insertions(+)


diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
--- a/drivers/usb/core/devio.c  2004-08-23 13:17:57 -07:00
+++ b/drivers/usb/core/devio.c  2004-08-23 13:17:57 -07:00
@@ -555,8 +555,10 @@
                snoop(&dev->dev, "control read: bRequest=%02x bRrequestType=%02x 
wValue=%04x wIndex=%04x\n", 
                        ctrl.bRequest, ctrl.bRequestType, ctrl.wValue, ctrl.wIndex);
 
+               up(&dev->serialize);
                i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, 
ctrl.bRequestType,
                                       ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, 
tmo);
+               down(&dev->serialize);
                if ((i > 0) && ctrl.wLength) {
                        if (usbfs_snoop) {
                                dev_info(&dev->dev, "control read: data ");
@@ -584,8 +586,10 @@
                                printk ("%02x ", (unsigned char)(tbuf)[j]);
                        printk("\n");
                }
+               up(&dev->serialize);
                i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, 
ctrl.bRequestType,
                                       ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, 
tmo);
+               down(&dev->serialize);
        }
        free_page((unsigned long)tbuf);
        if (i<0) {
@@ -627,7 +631,9 @@
                        kfree(tbuf);
                        return -EINVAL;
                }
+               up(&dev->serialize);
                i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
+               down(&dev->serialize);
                if (!i && len2) {
                        if (copy_to_user(bulk.data, tbuf, len2)) {
                                kfree(tbuf);
@@ -641,7 +647,9 @@
                                return -EFAULT;
                        }
                }
+               up(&dev->serialize);
                i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
+               down(&dev->serialize);
        }
        kfree(tbuf);
        if (i < 0) {



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to