From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDE0A3A7F41; Sat, 17 Oct 2026 17:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792256696; cv=none; b=XEMrvDhV9oMev4a4+XqnXkneCh4MGDOlD6m2acWYnO/n4uIqvxR0DbHEs+dm/S+Xf7S+Q2Enqh3CBF5zn/tGTeo3fAps7OBxU9w0bCwthmr14aPvz3WUp7spBJ/kdMy0yiqYompGngW4zA9AlP7sEAP2Db4QgSS0uOtlYUe4nck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792256696; c=relaxed/simple; bh=4tvmy5bSqOwc6CBbTjnfjmzQsh0wprKG2PWX4OmBCao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S4iYxQhJeoAe4qaeweJYwotc5RODpcnXTDJ4cTO1tpa7zgWKADK0sVasTv6pxp+QdIKzma/z7606ESvGzDC2bFD+ejVTecACIeDtkZef1vMy/nDBnytFB7eTylhmwBnfBVDV4Rs02UDd2hyqQx29z+PuNq4amQG+W3DLOd2TRlA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RErGW6rh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="RErGW6rh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 357E01F000C4; Sat, 17 Oct 2026 17:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792256694; bh=ocrcLjTV2b4M9oLxJv6xK/W3WFBEFMdvIbWGQleaQ7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RErGW6rh0bbkrKQpn6pDQYsFQze5uXo7SQtiUh3DodqFXnuA8jCvGOa9fGPT9i5ho fUFpXWqnJDKmiw8JEY0KQiApo7DcDsJQ+bmBVTm3BMo3TqFIhA0ShOkkpHY8BcAdRr 23WLsuJr1MHrKQx6TTWtZHUyV+diajyxSSELJi7A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bill Pemberton , Johan Hovold Subject: [PATCH 6.6 0321/1674] USB: serial: quatech2: fix baud rate overflow Date: Sat, 17 Oct 2026 17:43:13 +0200 Message-ID: <20261017160439.357769674@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit ec06546b43b612cefc851558981b4955c0ef9e46 upstream. The requested baud rate is incorrectly truncated to 16 bits so that line speeds above 65535 bps cannot be set. Use 32 bits for the rate while rejecting rates outside of [50,921600] to avoid having the 16-bit divisor overflow. Fixes: f7a33e608d9a ("USB: serial: add quatech2 usb to serial driver") Cc: stable@vger.kernel.org # 3.5 Cc: Bill Pemberton Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/quatech2.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -54,6 +54,7 @@ #define QT2_XMIT_FLUSH 0x05 /* no following info */ #define QT2_CONTROL_ESCAPE 0xff /* pass through previous 2 control bytes */ +#define MIN_BAUD_RATE 50 #define MAX_BAUD_RATE 921600 #define DEFAULT_BAUD_RATE 9600 @@ -158,7 +159,7 @@ static inline int calc_baud_divisor(int static inline int qt2_set_port_config(struct usb_device *dev, unsigned char port_number, - u16 baudrate, u16 lcr) + speed_t baudrate, u16 lcr) { int divisor = calc_baud_divisor(baudrate); u16 index = ((u16) (lcr << 8) | (u16) (port_number)); @@ -259,9 +260,9 @@ static void qt2_set_termios(struct tty_s struct usb_device *dev = port->serial->dev; struct qt2_port_private *port_priv; struct ktermios *termios = &tty->termios; - u16 baud; unsigned int cflag = termios->c_cflag; u16 new_lcr = 0; + speed_t baud; int status; port_priv = usb_get_serial_port_data(port); @@ -279,6 +280,18 @@ static void qt2_set_termios(struct tty_s if (!baud) baud = 9600; + if (baud < MIN_BAUD_RATE || baud > MAX_BAUD_RATE) { + if (old_termios) + baud = tty_termios_baud_rate(old_termios); + else + baud = clamp(baud, MIN_BAUD_RATE, MAX_BAUD_RATE); + + tty_encode_baud_rate(tty, baud, baud); + + if (!baud) + baud = 9600; + } + status = qt2_set_port_config(dev, port_priv->device_port, baud, new_lcr); if (status < 0) @@ -375,7 +388,7 @@ static int qt2_open(struct tty_struct *t port_priv->device_port = (u8) device_port; if (tty) - qt2_set_termios(tty, port, &tty->termios); + qt2_set_termios(tty, port, NULL); return 0;