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]>
--- local_tree.orig/drivers/usb/core/devio.c 2004-08-04 10:47:26.000000000 +0200
+++ local_tree/drivers/usb/core/devio.c 2004-08-06 09:58:21.907095209 +0200
@@ -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) {
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel