Greg:

This patch fixes a simple error in a couple of utility routines.  They 
will no longer try to dereference a NULL actconfig pointer.  Also, they 
will work a little better if the configuration is changed while they are 
running (which should never happen anyway).

Alan Stern


--- 2.6/drivers/usb/core/usb.c.orig     Wed Jan 21 11:55:45 2004
+++ 2.6/drivers/usb/core/usb.c  Wed Jan 21 12:42:59 2004
@@ -206,12 +206,15 @@
  */
 struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
 {
+       struct usb_host_config *config = dev->actconfig;
        int i;
 
-       for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++)
-               if (dev->actconfig->interface[i]->altsetting[0]
+       if (!config)
+               return NULL;
+       for (i = 0; i < config->desc.bNumInterfaces; i++)
+               if (config->interface[i]->altsetting[0]
                                .desc.bInterfaceNumber == ifnum)
-                       return dev->actconfig->interface[i];
+                       return config->interface[i];
 
        return NULL;
 }
@@ -233,14 +236,17 @@
 struct usb_endpoint_descriptor *
 usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum)
 {
+       struct usb_host_config *config = dev->actconfig;
        int i, k;
 
-       for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
+       if (!config)
+               return NULL;
+       for (i = 0; i < config->desc.bNumInterfaces; i++) {
                struct usb_interface            *intf;
                struct usb_host_interface       *alt;
 
-               /* only endpoints in current altseting are active */
-               intf = dev->actconfig->interface[i];
+               /* only endpoints in current altsetting are active */
+               intf = config->interface[i];
                alt = intf->altsetting + intf->act_altsetting;
 
                for (k = 0; k < alt->desc.bNumEndpoints; k++)



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to