Skip to content

Commit

Permalink
USB: quatech2: fix io after disconnect
Browse files Browse the repository at this point in the history
Make sure no control urb is submitted during close after a disconnect by
checking the disconnected flag.

Cc: <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed Oct 25, 2012
1 parent 8e512ab commit 2f0295a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/usb/serial/quatech2.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ static void qt2_close(struct usb_serial_port *port)
port_priv->urb_in_use = false;
spin_unlock_irqrestore(&port_priv->urb_lock, flags);

mutex_lock(&port->serial->disc_mutex);
if (port->serial->disconnected) {
mutex_unlock(&port->serial->disc_mutex);
return;
}

/* flush the port transmit buffer */
i = usb_control_msg(serial->dev,
usb_rcvctrlpipe(serial->dev, 0),
Expand Down Expand Up @@ -458,6 +464,7 @@ static void qt2_close(struct usb_serial_port *port)
dev_err(&port->dev, "%s - close port failed %i\n",
__func__, i);

mutex_unlock(&port->serial->disc_mutex);
}

static void qt2_disconnect(struct usb_serial *serial)
Expand Down

0 comments on commit 2f0295a

Please sign in to comment.