Commit af581059 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: io_ti: fix abuse of interface data

Fix abuse of interface data which was used to signal device disconnect.

Use the usb_serial disconnect flag and mutex where appropriate.

Note that there's no need to grab the mutex in chase_port as it does not
access the device.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5c0c7582
...@@ -547,6 +547,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout, ...@@ -547,6 +547,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
{ {
int baud_rate; int baud_rate;
struct tty_struct *tty = tty_port_tty_get(&port->port->port); struct tty_struct *tty = tty_port_tty_get(&port->port->port);
struct usb_serial *serial = port->port->serial;
wait_queue_t wait; wait_queue_t wait;
unsigned long flags; unsigned long flags;
...@@ -561,7 +562,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout, ...@@ -561,7 +562,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (kfifo_len(&port->write_fifo) == 0 if (kfifo_len(&port->write_fifo) == 0
|| timeout == 0 || signal_pending(current) || timeout == 0 || signal_pending(current)
|| !usb_get_intfdata(port->port->serial->interface)) || serial->disconnected)
/* disconnect */ /* disconnect */
break; break;
spin_unlock_irqrestore(&port->ep_lock, flags); spin_unlock_irqrestore(&port->ep_lock, flags);
...@@ -578,7 +579,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout, ...@@ -578,7 +579,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
/* wait for data to drain from the device */ /* wait for data to drain from the device */
timeout += jiffies; timeout += jiffies;
while ((long)(jiffies - timeout) < 0 && !signal_pending(current) while ((long)(jiffies - timeout) < 0 && !signal_pending(current)
&& usb_get_intfdata(port->port->serial->interface)) { && !serial->disconnected) {
/* not disconnected */ /* not disconnected */
if (!tx_active(port)) if (!tx_active(port))
break; break;
...@@ -586,7 +587,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout, ...@@ -586,7 +587,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
} }
/* disconnected */ /* disconnected */
if (!usb_get_intfdata(port->port->serial->interface)) if (serial->disconnected)
return; return;
/* wait one more character time, based on baud rate */ /* wait one more character time, based on baud rate */
...@@ -2003,8 +2004,8 @@ static void edge_close(struct usb_serial_port *port) ...@@ -2003,8 +2004,8 @@ static void edge_close(struct usb_serial_port *port)
{ {
struct edgeport_serial *edge_serial; struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port; struct edgeport_port *edge_port;
struct usb_serial *serial = port->serial;
int port_number; int port_number;
int status;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -2028,12 +2029,18 @@ static void edge_close(struct usb_serial_port *port) ...@@ -2028,12 +2029,18 @@ static void edge_close(struct usb_serial_port *port)
* send a close port command to it */ * send a close port command to it */
dbg("%s - send umpc_close_port", __func__); dbg("%s - send umpc_close_port", __func__);
port_number = port->number - port->serial->minor; port_number = port->number - port->serial->minor;
status = send_cmd(port->serial->dev,
mutex_lock(&serial->disc_mutex);
if (!serial->disconnected) {
send_cmd(serial->dev,
UMPC_CLOSE_PORT, UMPC_CLOSE_PORT,
(__u8)(UMPM_UART1_PORT + port_number), (__u8)(UMPM_UART1_PORT + port_number),
0, 0,
NULL, NULL,
0); 0);
}
mutex_unlock(&serial->disc_mutex);
mutex_lock(&edge_serial->es_lock); mutex_lock(&edge_serial->es_lock);
--edge_port->edge_serial->num_ports_open; --edge_port->edge_serial->num_ports_open;
if (edge_port->edge_serial->num_ports_open <= 0) { if (edge_port->edge_serial->num_ports_open <= 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment