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

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

USB: usb-serial: replace shutdown with disconnect, release



This patch (as1254) splits up the shutdown method of usb_serial_driver
into a disconnect and a release method.

The problem is that the usb-serial core was calling shutdown during
disconnect handling, but drivers didn't expect it to be called until
after all the open file references had been closed.  The result was an
oops when the close method tried to use memory that had been
deallocated by shutdown.

Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c706ebdf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2336,7 +2336,7 @@ static int ATEN2011_startup(struct usb_serial *serial)
	return 0;
}

static void ATEN2011_shutdown(struct usb_serial *serial)
static void ATEN2011_release(struct usb_serial *serial)
{
	int i;
	struct ATENINTL_port *ATEN2011_port;
@@ -2382,7 +2382,7 @@ static struct usb_serial_driver aten_serial_driver = {
	.tiocmget =		ATEN2011_tiocmget,
	.tiocmset =		ATEN2011_tiocmset,
	.attach =		ATEN2011_startup,
	.shutdown =		ATEN2011_shutdown,
	.release =		ATEN2011_release,
	.read_bulk_callback =	ATEN2011_bulk_in_callback,
	.read_int_callback =	ATEN2011_interrupt_callback,
};
+2 −3
Original line number Diff line number Diff line
@@ -364,7 +364,7 @@ static int aircable_attach(struct usb_serial *serial)
	return 0;
}

static void aircable_shutdown(struct usb_serial *serial)
static void aircable_release(struct usb_serial *serial)
{

	struct usb_serial_port *port = serial->port[0];
@@ -375,7 +375,6 @@ static void aircable_shutdown(struct usb_serial *serial)
	if (priv) {
		serial_buf_free(priv->tx_buf);
		serial_buf_free(priv->rx_buf);
		usb_set_serial_port_data(port, NULL);
		kfree(priv);
	}
}
@@ -601,7 +600,7 @@ static struct usb_serial_driver aircable_device = {
	.num_ports =		1,
	.attach =		aircable_attach,
	.probe =		aircable_probe,
	.shutdown =		aircable_shutdown,
	.release =		aircable_release,
	.write =		aircable_write,
	.write_room =		aircable_write_room,
	.write_bulk_callback =	aircable_write_bulk_callback,
+3 −4
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ static int debug;

/* function prototypes for a Belkin USB Serial Adapter F5U103 */
static int  belkin_sa_startup(struct usb_serial *serial);
static void belkin_sa_shutdown(struct usb_serial *serial);
static void belkin_sa_release(struct usb_serial *serial);
static int  belkin_sa_open(struct tty_struct *tty,
			struct usb_serial_port *port, struct file *filp);
static void belkin_sa_close(struct usb_serial_port *port);
@@ -142,7 +142,7 @@ static struct usb_serial_driver belkin_device = {
	.tiocmget =		belkin_sa_tiocmget,
	.tiocmset =		belkin_sa_tiocmset,
	.attach =		belkin_sa_startup,
	.shutdown =		belkin_sa_shutdown,
	.release =		belkin_sa_release,
};


@@ -197,14 +197,13 @@ static int belkin_sa_startup(struct usb_serial *serial)
}


static void belkin_sa_shutdown(struct usb_serial *serial)
static void belkin_sa_release(struct usb_serial *serial)
{
	struct belkin_sa_private *priv;
	int i;

	dbg("%s", __func__);

	/* stop reads and writes on all ports */
	for (i = 0; i < serial->num_ports; ++i) {
		/* My special items, the standard routines free my urbs */
		priv = usb_get_serial_port_data(serial->port[i]);
+3 −3
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port, struct file *,
		unsigned int, unsigned int);
static void cp210x_break_ctl(struct tty_struct *, int);
static int cp210x_startup(struct usb_serial *);
static void cp210x_shutdown(struct usb_serial *);
static void cp210x_disconnect(struct usb_serial *);

static int debug;

@@ -137,7 +137,7 @@ static struct usb_serial_driver cp210x_device = {
	.tiocmget 		= cp210x_tiocmget,
	.tiocmset		= cp210x_tiocmset,
	.attach			= cp210x_startup,
	.shutdown		= cp210x_shutdown,
	.disconnect		= cp210x_disconnect,
};

/* Config request types */
@@ -792,7 +792,7 @@ static int cp210x_startup(struct usb_serial *serial)
	return 0;
}

static void cp210x_shutdown(struct usb_serial *serial)
static void cp210x_disconnect(struct usb_serial *serial)
{
	int i;

+15 −5
Original line number Diff line number Diff line
@@ -58,7 +58,8 @@ static int debug;

/* Function prototypes */
static int cyberjack_startup(struct usb_serial *serial);
static void cyberjack_shutdown(struct usb_serial *serial);
static void cyberjack_disconnect(struct usb_serial *serial);
static void cyberjack_release(struct usb_serial *serial);
static int  cyberjack_open(struct tty_struct *tty,
			struct usb_serial_port *port, struct file *filp);
static void cyberjack_close(struct usb_serial_port *port);
@@ -94,7 +95,8 @@ static struct usb_serial_driver cyberjack_device = {
	.id_table =		id_table,
	.num_ports =		1,
	.attach =		cyberjack_startup,
	.shutdown =		cyberjack_shutdown,
	.disconnect =		cyberjack_disconnect,
	.release =		cyberjack_release,
	.open =			cyberjack_open,
	.close =		cyberjack_close,
	.write =		cyberjack_write,
@@ -148,17 +150,25 @@ static int cyberjack_startup(struct usb_serial *serial)
	return 0;
}

static void cyberjack_shutdown(struct usb_serial *serial)
static void cyberjack_disconnect(struct usb_serial *serial)
{
	int i;

	dbg("%s", __func__);

	for (i = 0; i < serial->num_ports; ++i) {
	for (i = 0; i < serial->num_ports; ++i)
		usb_kill_urb(serial->port[i]->interrupt_in_urb);
}

static void cyberjack_release(struct usb_serial *serial)
{
	int i;

	dbg("%s", __func__);

	for (i = 0; i < serial->num_ports; ++i) {
		/* My special items, the standard routines free my urbs */
		kfree(usb_get_serial_port_data(serial->port[i]));
		usb_set_serial_port_data(serial->port[i], NULL);
	}
}

Loading