Hi,

Here's a patch against 2.4.10-pre8 that fixes a potential problem in the
usb-serial startup code.  If the usb_register function fails, the
generic driver is still registered with the usb_serial core causing a
memory leak.  Thanks to Randy Dunlap for pointing out this problem to
me.

thanks,

greg k-h



diff -Nru a/drivers/usb/serial/usbserial.c b/drivers/usb/serial/usbserial.c
--- a/drivers/usb/serial/usbserial.c    Thu Sep 13 11:37:11 2001
+++ b/drivers/usb/serial/usbserial.c    Thu Sep 13 11:37:11 2001
@@ -15,6 +15,10 @@
  *
  * See Documentation/usb/usb-serial.txt for more information on using this driver
  * 
+ * (09/13/2001) gkh
+ *     Moved generic driver initialize after we have registered with the USB
+ *     core.  Thanks to Randy Dunlap for pointing this problem out.
+ *
  * (07/03/2001) gkh
  *     Fixed module paramater size.  Thanks to John Brockmeyer for the pointer.
  *     Fixed vendor and product getting defined through the MODULE_PARM macro
@@ -1426,14 +1430,6 @@
                return -1;
        }
 
-#ifdef CONFIG_USB_SERIAL_GENERIC
-       generic_device_ids[0].idVendor = vendor;
-       generic_device_ids[0].idProduct = product;
-       generic_device_ids[0].match_flags = USB_DEVICE_ID_MATCH_VENDOR | 
USB_DEVICE_ID_MATCH_PRODUCT;
-       /* register our generic driver with ourselves */
-       usb_serial_register (&generic_device);
-#endif
-       
        /* register the USB driver */
        result = usb_register(&usb_serial_driver);
        if (result < 0) {
@@ -1441,6 +1437,14 @@
                err("usb_register failed for the usb-serial driver. Error number %d", 
result);
                return -1;
        }
+
+#ifdef CONFIG_USB_SERIAL_GENERIC
+       generic_device_ids[0].idVendor = vendor;
+       generic_device_ids[0].idProduct = product;
+       generic_device_ids[0].match_flags = USB_DEVICE_ID_MATCH_VENDOR | 
+USB_DEVICE_ID_MATCH_PRODUCT;
+       /* register our generic driver with ourselves */
+       usb_serial_register (&generic_device);
+#endif
 
        info(DRIVER_DESC " " DRIVER_VERSION);
 

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to