diff options
author | Johan Hovold <jhovold@gmail.com> | 2013-06-10 12:29:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-10 14:00:49 -0400 |
commit | 2d8f4447b58bba5f8cb895c07690434c02307eaf (patch) | |
tree | 149d98e65204272b6ecb73c1976fd90334bc5a49 /drivers/usb/serial | |
parent | 5e4211f1c47560c36a8b3d4544dfd866dcf7ccd0 (diff) |
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: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/pl2303.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 7151659367a0..048cd44d51b1 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -284,7 +284,7 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
284 | serial settings even to the same values as before. Thus | 284 | serial settings even to the same values as before. Thus |
285 | we actually need to filter in this specific case */ | 285 | we actually need to filter in this specific case */ |
286 | 286 | ||
287 | if (!tty_termios_hw_change(&tty->termios, old_termios)) | 287 | if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios)) |
288 | return; | 288 | return; |
289 | 289 | ||
290 | cflag = tty->termios.c_cflag; | 290 | cflag = tty->termios.c_cflag; |
@@ -293,7 +293,8 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
293 | if (!buf) { | 293 | if (!buf) { |
294 | dev_err(&port->dev, "%s - out of memory.\n", __func__); | 294 | dev_err(&port->dev, "%s - out of memory.\n", __func__); |
295 | /* Report back no change occurred */ | 295 | /* Report back no change occurred */ |
296 | tty->termios = *old_termios; | 296 | if (old_termios) |
297 | tty->termios = *old_termios; | ||
297 | return; | 298 | return; |
298 | } | 299 | } |
299 | 300 | ||
@@ -433,7 +434,7 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
433 | control = priv->line_control; | 434 | control = priv->line_control; |
434 | if ((cflag & CBAUD) == B0) | 435 | if ((cflag & CBAUD) == B0) |
435 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); | 436 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); |
436 | else if ((old_termios->c_cflag & CBAUD) == B0) | 437 | else if (old_termios && (old_termios->c_cflag & CBAUD) == B0) |
437 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); | 438 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); |
438 | if (control != priv->line_control) { | 439 | if (control != priv->line_control) { |
439 | control = priv->line_control; | 440 | control = priv->line_control; |
@@ -492,7 +493,6 @@ static void pl2303_close(struct usb_serial_port *port) | |||
492 | 493 | ||
493 | static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) | 494 | static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) |
494 | { | 495 | { |
495 | struct ktermios tmp_termios; | ||
496 | struct usb_serial *serial = port->serial; | 496 | struct usb_serial *serial = port->serial; |
497 | struct pl2303_serial_private *spriv = usb_get_serial_data(serial); | 497 | struct pl2303_serial_private *spriv = usb_get_serial_data(serial); |
498 | int result; | 498 | int result; |
@@ -508,7 +508,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
508 | 508 | ||
509 | /* Setup termios */ | 509 | /* Setup termios */ |
510 | if (tty) | 510 | if (tty) |
511 | pl2303_set_termios(tty, port, &tmp_termios); | 511 | pl2303_set_termios(tty, port, NULL); |
512 | 512 | ||
513 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 513 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
514 | if (result) { | 514 | if (result) { |