ChangeSet 1.1474.148.17, 2004/01/26 17:11:51-08:00, [EMAIL PROTECTED]

[PATCH] USB: Don't dereference NULL actconfig

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


 drivers/usb/core/usb.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)


diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c    Tue Jan 27 15:12:48 2004
+++ b/drivers/usb/core/usb.c    Tue Jan 27 15:12:48 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