Skip to content

Commit

Permalink
USB: spcp8x5: fix device initialisation at open
Browse files Browse the repository at this point in the history
Do not use uninitialised termios data to determine when to configure the
device at open.

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 Jun 10, 2013
1 parent 2188672 commit 5e4211f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/usb/serial/spcp8x5.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,23 +291,22 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
struct spcp8x5_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
unsigned int cflag = tty->termios.c_cflag;
unsigned int old_cflag = old_termios->c_cflag;
unsigned short uartdata;
unsigned char buf[2] = {0, 0};
int baud;
int i;
u8 control;

/* check that they really want us to change something */
if (!tty_termios_hw_change(&tty->termios, old_termios))
if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
return;

/* set DTR/RTS active */
spin_lock_irqsave(&priv->lock, flags);
control = priv->line_control;
if ((old_cflag & CBAUD) == B0) {
if (old_termios && (old_termios->c_cflag & CBAUD) == B0) {
priv->line_control |= MCR_DTR;
if (!(old_cflag & CRTSCTS))
if (!(old_termios->c_cflag & CRTSCTS))
priv->line_control |= MCR_RTS;
}
if (control != priv->line_control) {
Expand Down Expand Up @@ -394,7 +393,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty,

static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
{
struct ktermios tmp_termios;
struct usb_serial *serial = port->serial;
struct spcp8x5_private *priv = usb_get_serial_port_data(port);
int ret;
Expand All @@ -411,7 +409,7 @@ static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
spcp8x5_set_ctrl_line(port, priv->line_control);

if (tty)
spcp8x5_set_termios(tty, port, &tmp_termios);
spcp8x5_set_termios(tty, port, NULL);

port->port.drain_delay = 256;

Expand Down

0 comments on commit 5e4211f

Please sign in to comment.