Skip to content

Commit

Permalink
USB: pl2303: enforce baud-rate limits before lookup
Browse files Browse the repository at this point in the history
Enforce any baud-rate limits before doing table lookup.

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 Jan 3, 2014
1 parent 59afe10 commit 871996e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/usb/serial/pl2303.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ static void pl2303_encode_baud_rate(struct tty_struct *tty,
dev_dbg(&port->dev, "baud requested = %u\n", baud);
if (!baud)
return;

if (spriv->type->max_baud_rate)
baud = min_t(speed_t, baud, spriv->type->max_baud_rate);
/*
* Set baud rate to nearest supported value.
*
Expand All @@ -359,9 +362,6 @@ static void pl2303_encode_baud_rate(struct tty_struct *tty,
*/
baud = pl2303_get_supported_baud_rate(baud);

if (spriv->type->max_baud_rate)
baud = min_t(speed_t, baud, spriv->type->max_baud_rate);

if (baud <= 115200) {
put_unaligned_le32(baud, buf);
} else {
Expand Down

0 comments on commit 871996e

Please sign in to comment.