Sean and Matthias:

Can you try installing this patch in place of the earlier one?  It's 
somewhat safer, and if gphoto2 works with it then I will submit it for 
inclusion in the distribution kernel.

Thanks,

Alan Stern


===== devio.c 1.88 vs edited =====
--- 1.88/drivers/usb/core/devio.c       Wed Mar 17 14:16:46 2004
+++ edited/drivers/usb/core/devio.c     Tue Mar 23 09:39:53 2004
@@ -414,6 +414,8 @@
 
        if (ep & ~(USB_DIR_IN|0xf))
                return -EINVAL;
+       if (!dev->actconfig)
+               return -ESRCH;
        for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
                iface = dev->actconfig->interface[i];
                for (j = 0; j < iface->num_altsetting; j++) {
@@ -434,6 +436,8 @@
 
        if (ifn & ~0xff)
                return -EINVAL;
+       if (!dev->actconfig)
+               return -ESRCH;
        for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
                if (dev->actconfig->interface[i]->
                                altsetting[0].desc.bInterfaceNumber == ifn)
@@ -750,10 +754,26 @@
 static int proc_setconfig(struct dev_state *ps, void __user *arg)
 {
        unsigned int u;
+       struct usb_host_config *actconfig = ps->dev->actconfig;
 
        if (get_user(u, (unsigned int __user *)arg))
                return -EFAULT;
-       return usb_set_configuration(ps->dev, u);
+
+       /* Don't change the configuration if any interfaces are claimed.
+        * It would interfere with other drivers' operations, and if an
+        * interface is claimed by usbfs it would cause deadlock. */
+       if (actconfig) {
+               int i;
+
+               for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) {
+                       if (usb_interface_claimed(actconfig->interface[i]))
+                               return -EBUSY;
+               }
+       }
+       if (actconfig && actconfig->desc.bConfigurationValue == u)
+               return usb_reset_configuration(ps->dev);
+       else
+               return usb_set_configuration(ps->dev, u);
 }
 
 static int proc_submiturb(struct dev_state *ps, void __user *arg)



-------------------------------------------------------
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