Skip to content

Commit 57845bd

Browse files
lyakhgregkh
authored andcommitted
[PATCH] USB: console: fix oops
Prevent NULL dereference when used as a USB-serial console. Signed-off-by: Guennadi Liakhovetski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c10746d commit 57845bd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/usb/serial/ftdi_sio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,6 @@ static void ftdi_shutdown (struct usb_serial *serial)
12611261

12621262
static int ftdi_open (struct usb_serial_port *port, struct file *filp)
12631263
{ /* ftdi_open */
1264-
struct termios tmp_termios;
12651264
struct usb_device *dev = port->serial->dev;
12661265
struct ftdi_private *priv = usb_get_serial_port_data(port);
12671266
unsigned long flags;
@@ -1271,8 +1270,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
12711270

12721271
dbg("%s", __FUNCTION__);
12731272

1274-
1275-
port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1273+
if (port->tty)
1274+
port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
12761275

12771276
/* No error checking for this (will get errors later anyway) */
12781277
/* See ftdi_sio.h for description of what is reset */
@@ -1286,7 +1285,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
12861285
This is same behaviour as serial.c/rs_open() - Kuba */
12871286

12881287
/* ftdi_set_termios will send usb control messages */
1289-
ftdi_set_termios(port, &tmp_termios);
1288+
if (port->tty)
1289+
ftdi_set_termios(port, NULL);
12901290

12911291
/* FIXME: Flow control might be enabled, so it should be checked -
12921292
we have no control of defaults! */
@@ -1867,7 +1867,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
18671867
err("%s urb failed to set baudrate", __FUNCTION__);
18681868
}
18691869
/* Ensure RTS and DTR are raised when baudrate changed from 0 */
1870-
if ((old_termios->c_cflag & CBAUD) == B0) {
1870+
if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) {
18711871
set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
18721872
}
18731873
}

0 commit comments

Comments
 (0)