Commit 2d8f4447 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: pl2303: fix device initialisation at open

Do not use uninitialised termios data to determine when to configure the
device at open.

This also prevents stack data from leaking to userspace in the OOM error
path.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5e4211f1
...@@ -284,7 +284,7 @@ static void pl2303_set_termios(struct tty_struct *tty, ...@@ -284,7 +284,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
serial settings even to the same values as before. Thus serial settings even to the same values as before. Thus
we actually need to filter in this specific case */ we actually need to filter in this specific case */
if (!tty_termios_hw_change(&tty->termios, old_termios)) if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
return; return;
cflag = tty->termios.c_cflag; cflag = tty->termios.c_cflag;
...@@ -293,7 +293,8 @@ static void pl2303_set_termios(struct tty_struct *tty, ...@@ -293,7 +293,8 @@ static void pl2303_set_termios(struct tty_struct *tty,
if (!buf) { if (!buf) {
dev_err(&port->dev, "%s - out of memory.\n", __func__); dev_err(&port->dev, "%s - out of memory.\n", __func__);
/* Report back no change occurred */ /* Report back no change occurred */
tty->termios = *old_termios; if (old_termios)
tty->termios = *old_termios;
return; return;
} }
...@@ -433,7 +434,7 @@ static void pl2303_set_termios(struct tty_struct *tty, ...@@ -433,7 +434,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
control = priv->line_control; control = priv->line_control;
if ((cflag & CBAUD) == B0) if ((cflag & CBAUD) == B0)
priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
else if ((old_termios->c_cflag & CBAUD) == B0) else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
priv->line_control |= (CONTROL_DTR | CONTROL_RTS); priv->line_control |= (CONTROL_DTR | CONTROL_RTS);
if (control != priv->line_control) { if (control != priv->line_control) {
control = priv->line_control; control = priv->line_control;
...@@ -492,7 +493,6 @@ static void pl2303_close(struct usb_serial_port *port) ...@@ -492,7 +493,6 @@ static void pl2303_close(struct usb_serial_port *port)
static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
{ {
struct ktermios tmp_termios;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct pl2303_serial_private *spriv = usb_get_serial_data(serial); struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
int result; int result;
...@@ -508,7 +508,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -508,7 +508,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
/* Setup termios */ /* Setup termios */
if (tty) if (tty)
pl2303_set_termios(tty, port, &tmp_termios); pl2303_set_termios(tty, port, NULL);
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
if (result) { if (result) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment