diff options
author | Johan Hovold <jhovold@gmail.com> | 2012-04-25 09:56:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-25 14:37:18 -0400 |
commit | 81d5a6729018ef18dcc1a555144ce91eb3c9abc4 (patch) | |
tree | 92e3fa4fa694477ff8a6210fb2bc590959e45e56 /drivers | |
parent | 33f7a67e477f780b82ef36ce358f6d5290d6a9b2 (diff) |
USB: opticon: 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 'drivers')
-rw-r--r-- | drivers/usb/serial/opticon.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index 82cc9d202b83..d31e997ebd27 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
@@ -401,8 +401,6 @@ static int opticon_tiocmget(struct tty_struct *tty) | |||
401 | int result = 0; | 401 | int result = 0; |
402 | 402 | ||
403 | dbg("%s - port %d", __func__, port->number); | 403 | dbg("%s - port %d", __func__, port->number); |
404 | if (!usb_get_intfdata(port->serial->interface)) | ||
405 | return -ENODEV; | ||
406 | 404 | ||
407 | spin_lock_irqsave(&priv->lock, flags); | 405 | spin_lock_irqsave(&priv->lock, flags); |
408 | if (priv->rts) | 406 | if (priv->rts) |
@@ -419,13 +417,13 @@ static int opticon_tiocmset(struct tty_struct *tty, | |||
419 | unsigned int set, unsigned int clear) | 417 | unsigned int set, unsigned int clear) |
420 | { | 418 | { |
421 | struct usb_serial_port *port = tty->driver_data; | 419 | struct usb_serial_port *port = tty->driver_data; |
420 | struct usb_serial *serial = port->serial; | ||
422 | struct opticon_private *priv = usb_get_serial_data(port->serial); | 421 | struct opticon_private *priv = usb_get_serial_data(port->serial); |
423 | unsigned long flags; | 422 | unsigned long flags; |
424 | bool rts; | 423 | bool rts; |
425 | bool changed = false; | 424 | bool changed = false; |
425 | int ret; | ||
426 | 426 | ||
427 | if (!usb_get_intfdata(port->serial->interface)) | ||
428 | return -ENODEV; | ||
429 | /* We only support RTS so we only handle that */ | 427 | /* We only support RTS so we only handle that */ |
430 | spin_lock_irqsave(&priv->lock, flags); | 428 | spin_lock_irqsave(&priv->lock, flags); |
431 | 429 | ||
@@ -441,7 +439,14 @@ static int opticon_tiocmset(struct tty_struct *tty, | |||
441 | return 0; | 439 | return 0; |
442 | 440 | ||
443 | /* Send the new RTS state to the connected device */ | 441 | /* Send the new RTS state to the connected device */ |
444 | return send_control_msg(port, CONTROL_RTS, !rts); | 442 | mutex_lock(&serial->disc_mutex); |
443 | if (!serial->disconnected) | ||
444 | ret = send_control_msg(port, CONTROL_RTS, !rts); | ||
445 | else | ||
446 | ret = -ENODEV; | ||
447 | mutex_unlock(&serial->disc_mutex); | ||
448 | |||
449 | return ret; | ||
445 | } | 450 | } |
446 | 451 | ||
447 | static int get_serial_info(struct opticon_private *priv, | 452 | static int get_serial_info(struct opticon_private *priv, |