]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
usb-serial: don't release unregistered minors
authorAlan Stern <stern@rowland.harvard.edu>
Tue, 29 Jul 2008 16:01:04 +0000 (12:01 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 14 Aug 2008 00:32:50 +0000 (17:32 -0700)
This patch (as1121) fixes a bug in the USB serial core.  When a device
is unregistered, the core will give back its minors -- even if the
device hasn't been assigned any!

The patch reserves the highest minor value (255) to mean that no minor
was assigned.  It also removes some dead code and does a small style
fixup.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/usb-serial.c
include/linux/usb/serial.h

index 8c2d531eedea1f3bf2759ec9796dcf96cb8dcfff..b157c48e8b78df594bd0386f5ff38a725cf18929 100644 (file)
@@ -122,9 +122,6 @@ static void return_serial(struct usb_serial *serial)
 
        dbg("%s", __func__);
 
-       if (serial == NULL)
-               return;
-
        for (i = 0; i < serial->num_ports; ++i)
                serial_table[serial->minor + i] = NULL;
 }
@@ -142,7 +139,8 @@ static void destroy_serial(struct kref *kref)
        serial->type->shutdown(serial);
 
        /* return the minor range that this device had */
-       return_serial(serial);
+       if (serial->minor != SERIAL_TTY_NO_MINOR)
+               return_serial(serial);
 
        for (i = 0; i < serial->num_ports; ++i)
                serial->port[i]->port.count = 0;
@@ -575,6 +573,7 @@ static struct usb_serial *create_serial(struct usb_device *dev,
        serial->interface = interface;
        kref_init(&serial->kref);
        mutex_init(&serial->disc_mutex);
+       serial->minor = SERIAL_TTY_NO_MINOR;
 
        return serial;
 }
index 09a3e6a7518fc2e043fd3568f95b74d822b78af6..655341d0f534a370f7966aa617b8733b52124acb 100644 (file)
@@ -17,7 +17,8 @@
 #include <linux/mutex.h>
 
 #define SERIAL_TTY_MAJOR       188     /* Nice legal number now */
-#define SERIAL_TTY_MINORS      255     /* loads of devices :) */
+#define SERIAL_TTY_MINORS      254     /* loads of devices :) */
+#define SERIAL_TTY_NO_MINOR    255     /* No minor was assigned */
 
 /* The maximum number of ports one device can grab at once */
 #define MAX_NUM_PORTS          8