summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb-serial.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-01-14 16:52:56 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-18 15:45:17 -0800
commit810360a03597afc0d43a45798a52cfb69b8453d3 (patch)
tree977253346afd738d334a73de671cbd9f2102d809 /drivers/usb/serial/usb-serial.c
parentfcdb6a21903bcab0b5f788ba7eb0c31dd06040fd (diff)
downloadtalos-op-linux-810360a03597afc0d43a45798a52cfb69b8453d3.tar.gz
talos-op-linux-810360a03597afc0d43a45798a52cfb69b8453d3.zip
USB: serial: grab disconnect mutex in chars_in_buffer
Grab disconnect mutex in chars_in_buffer before checking disconnected flag or calling driver specific function. This allows subdrivers to query any hardware buffer status without having to handle the locking themselves. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r--drivers/usb/serial/usb-serial.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 64bda135ba7e..0a17f5942552 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -361,15 +361,21 @@ static int serial_write_room(struct tty_struct *tty)
static int serial_chars_in_buffer(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
+ struct usb_serial *serial = port->serial;
+ int count = 0;
dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
+ mutex_lock(&serial->disc_mutex);
/* if the device was unplugged then any remaining characters
fell out of the connector ;) */
- if (port->serial->disconnected)
- return 0;
- /* pass on to the driver specific version of this function */
- return port->serial->type->chars_in_buffer(tty);
+ if (serial->disconnected)
+ count = 0;
+ else
+ count = serial->type->chars_in_buffer(tty);
+ mutex_unlock(&serial->disc_mutex);
+
+ return count;
}
static void serial_throttle(struct tty_struct *tty)
OpenPOWER on IntegriCloud