summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/pl2303.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2012-04-25 15:56:31 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-25 20:37:19 +0200
commit6f1efd6c5aa63ddcfe1ffc60ade716f5421766f4 (patch)
tree48386a18f24bd24f6ae857e0a3c1a43960c032c4 /drivers/usb/serial/pl2303.c
parentUSB: oti6858: fix abuse of interface data (diff)
downloadlinux-6f1efd6c5aa63ddcfe1ffc60ade716f5421766f4.tar.xz
linux-6f1efd6c5aa63ddcfe1ffc60ade716f5421766f4.zip
USB: pl2303: 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 tiocmget does not need to check for disconnect as it does not access the device. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to '')
-rw-r--r--drivers/usb/serial/pl2303.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index a1a9062954c4..4917b4e79bb5 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -523,12 +523,11 @@ static int pl2303_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear)
{
struct usb_serial_port *port = tty->driver_data;
+ struct usb_serial *serial = port->serial;
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
u8 control;
-
- if (!usb_get_intfdata(port->serial->interface))
- return -ENODEV;
+ int ret;
spin_lock_irqsave(&priv->lock, flags);
if (set & TIOCM_RTS)
@@ -542,7 +541,14 @@ static int pl2303_tiocmset(struct tty_struct *tty,
control = priv->line_control;
spin_unlock_irqrestore(&priv->lock, flags);
- return set_control_lines(port->serial->dev, control);
+ mutex_lock(&serial->disc_mutex);
+ if (!serial->disconnected)
+ ret = set_control_lines(serial->dev, control);
+ else
+ ret = -ENODEV;
+ mutex_unlock(&serial->disc_mutex);
+
+ return ret;
}
static int pl2303_tiocmget(struct tty_struct *tty)
@@ -556,9 +562,6 @@ static int pl2303_tiocmget(struct tty_struct *tty)
dbg("%s (%d)", __func__, port->number);
- if (!usb_get_intfdata(port->serial->interface))
- return -ENODEV;
-
spin_lock_irqsave(&priv->lock, flags);
mcr = priv->line_control;
status = priv->line_status;