[patch 03/49] usb-serial: dont release unregistered minors

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg KH
Date: Monday, August 18, 2008 - 12:19 pm

2.6.25-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Alan Stern <stern@rowland.harvard.edu>

commit 0282b7f2a874e72c18fcd5a112ccf67f71ba7f5c upstream

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/usb/serial/usb-serial.c |    7 +++----
 include/linux/usb/serial.h      |    3 ++-
 2 files changed, 5 insertions(+), 5 deletions(-)

--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -119,9 +119,6 @@ static void return_serial(struct usb_ser
 
 	dbg("%s", __FUNCTION__);
 
-	if (serial == NULL)
-		return;
-
 	for (i = 0; i < serial->num_ports; ++i) {
 		serial_table[serial->minor + i] = NULL;
 	}
@@ -140,7 +137,8 @@ static void destroy_serial(struct 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]->open_count = 0;
@@ -635,6 +633,7 @@ static struct usb_serial * create_serial
 	serial->interface = interface;
 	kref_init(&serial->kref);
 	mutex_init(&serial->disc_mutex);
+	serial->minor = SERIAL_TTY_NO_MINOR;
 
 	return serial;
 }
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -18,7 +18,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

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/49] 2.6.25-stable review, Greg KH, (Mon Aug 18, 12:18 pm)
[patch 03/49] usb-serial: dont release unregistered minors, Greg KH, (Mon Aug 18, 12:19 pm)
[patch 07/49] SCSI: ses: fix VPD inquiry overrun, Greg KH, (Mon Aug 18, 12:19 pm)
[patch 12/49] radeonfb: fix accel engine hangs, Greg KH, (Mon Aug 18, 12:19 pm)
[patch 15/49] mlock() fix return values, Greg KH, (Mon Aug 18, 12:19 pm)
[patch 23/49] random32: seeding improvement, Greg KH, (Mon Aug 18, 12:20 pm)
[patch 25/49] sparc64: FUTEX_OP_ANDN fix, Greg KH, (Mon Aug 18, 12:20 pm)
[patch 27/49] uml: fix build when SLOB is enabled, Greg KH, (Mon Aug 18, 12:20 pm)
[patch 30/49] uml: track and make up lost ticks, Greg KH, (Mon Aug 18, 12:20 pm)
[patch 39/49] uml: Fix boot crash, Greg KH, (Mon Aug 18, 12:20 pm)
[patch 40/49] uml: PATH_MAX needs limits.h, Greg KH, (Mon Aug 18, 12:20 pm)
[patch 41/49] radeon: misc corrections, Greg KH, (Mon Aug 18, 12:20 pm)
[patch 46/49] x86: fix spin_is_contended(), Greg KH, (Mon Aug 18, 12:21 pm)