From nobody Tue Nov 03 08:06:26 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jJh3q5J6mz6yJR5 for ; Tue, 03 Nov 2026 08:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jJh3q2m6lz3QyT for ; Tue, 03 Nov 2026 08:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793693191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=esaN/wvyt5XyAIf8wgTk3ZFD4bPTf5CSvZbb+aJWOEA=; b=Rp70S8fkAZrhTazNtGJjUVO9rZjZHdsrRsPNfeWvVUPkDgSJAk64nKmxbSP6L3kUGv9Ho+ XO49yAZjCh23UkHx0B9occgTVhOTz2VLQz2AezB9O45Wcyr1BN7za2jPFiCzTU6q6o+AhN vJq1C6ubm1lcRX/cK677IwUTEmisYSySgbGMoj4apeJ7P3AMkUCgLFVqy9UdeMhUsM8hy+ EboSxaEd/3BI3JW+oRyFWSJ7EYo1q84fiDRUNd98AqQf6jmKpDGiKbUlU59RrIroX6FIOj nUZsFope874stQQASroaP34z7hvOXl3U857LzdfWP6YRENqoi7pWiko/doMLlQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793693191; b=MXtCFjscUuIAfhbkLc17ypo79CXew1Vz2tfPlnJXMUkvLWDlqqyQBv8YzLr+oH8vW+A63F NdOBFhA7dOhyvYDRNr3NY8SwEDSHDaN0W4BiPi4XPZXZiyDmGVO3uJMbPj/QTT/Gsbre40 nq1JlF7NXvOZfUocDBD1rYMEcj/X0jt/lowpZrp0iz0WTzBZ84xcfK6PC0mQ4jmUxj9WdN IxX9qlf+7oFnVVgab1HTDN8I9hodJ/w7k1ARYae2hNzgW1PmLRE4EwYiIUeMX2XNLreZDi ufYHUjDOsPDUXxlLbtUgGiKgTT/WVI3c5r+MfJkTwCeJSvOfCHOCqqZsRxH3gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793693191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=esaN/wvyt5XyAIf8wgTk3ZFD4bPTf5CSvZbb+aJWOEA=; b=fXG15NtRuvzkXQi9hAV3N/fcaRZFw4d/x531SEfsVYwPsfMpMZ0ePDxA7MriQGMMVWookQ a/JaTdPEpznckymzSHpi8jRZxLAj8UASlY0yNAoblC04JVyalGEbZVUmzUZgLK25spGlHx zmTuBXLxpRDZdsuaem7EhLjrBYiTJRLE9K6qy9B2opOZtmydXCW5aWHcIGAD2AJuTYumHI zVS+t3ErNE9xjaTAjI+Nf7NKYBS73b0SiPYTjYS9vwihNV3XawGuhT+HQxewtbRTyst7wd 3eVUsFhMaBNseHjCNioRbpzS1MNpNsFsgR1HVPSGsGfeh02Q6zYJ69TGAzMuCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jJh3q2RXkz1N0k for ; Tue, 03 Nov 2026 08:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3ee76 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 03 Nov 2026 08:06:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Lo Subject: git: 418b14ae076f - main - uchcom: validate baud rate in uchcom_pre_param List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevlo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 418b14ae076f310cab21ee6aabe2a7389c80dbb0 Auto-Submitted: auto-generated Date: Tue, 03 Nov 2026 08:06:26 +0000 Message-Id: <6ae99602.3ee76.6083d12f@gitrepo.freebsd.org> The branch main has been updated by kevlo: URL: https://cgit.FreeBSD.org/src/commit/?id=418b14ae076f310cab21ee6aabe2a7389c80dbb0 commit 418b14ae076f310cab21ee6aabe2a7389c80dbb0 Author: Kevin Lo AuthorDate: 2026-11-03 08:04:21 +0000 Commit: Kevin Lo CommitDate: 2026-11-03 08:04:21 +0000 uchcom: validate baud rate in uchcom_pre_param Check the requested baud rate in uchcom_pre_param() instead of working around it in uchcom_calc_baudrate(), where a rate of 0 caused a divide-by-zero. The pre_param callback is the proper place for this check. Reviewed by: aokblast Differential Revision: https://reviews.freebsd.org/D61127 --- sys/dev/usb/serial/uchcom.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sys/dev/usb/serial/uchcom.c b/sys/dev/usb/serial/uchcom.c index d315b2d37c46..e64bd7e4eb57 100644 --- a/sys/dev/usb/serial/uchcom.c +++ b/sys/dev/usb/serial/uchcom.c @@ -628,9 +628,6 @@ uchcom_calc_baudrate(struct uchcom_softc *sc, uint32_t rate, uint8_t *divisor, *divisor = 0; } - if (rate == 0) - rate = 1; - *factor = 256 - clk / rate; if (rate == 921600 && sc->sc_chiptype != TYPE_CH343) { @@ -712,24 +709,24 @@ static int uchcom_pre_param(struct ucom_softc *ucom, struct termios *t) { struct uchcom_softc *sc = ucom->sc_parent; + uint32_t maxspeed; /* - * Check requested baud rate. * The CH340/CH341 can set any baud rate up to 2Mb. * The CH9102/CH343 can set any baud rate up to 6Mb. */ switch (sc->sc_chiptype) { case TYPE_CH343: - if (t->c_ospeed <= 6000000) - return (0); + maxspeed = 6000000; break; default: - if (t->c_ospeed <= 2000000) - return (0); + maxspeed = 2000000; break; } - return (EIO); + if (t->c_ospeed <= 0 || t->c_ospeed > maxspeed) + return (EINVAL); + return (0); } static void