Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0282b7f2 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

usb-serial: don't release unregistered minors



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: default avatarAlan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e67d70f2
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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,6 +139,7 @@ static void destroy_serial(struct kref *kref)
	serial->type->shutdown(serial);

	/* return the minor range that this device had */
	if (serial->minor != SERIAL_TTY_NO_MINOR)
		return_serial(serial);

	for (i = 0; i < serial->num_ports; ++i)
@@ -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;
}
+2 −1
Original line number Diff line number Diff line
@@ -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