git: 6b597a9470ad - stable/15 - uchcom: Set rate to 1 if 0
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 01 Nov 2026 22:08:36 UTC
The branch stable/15 has been updated by aokblast:
URL: https://cgit.FreeBSD.org/src/commit/?id=6b597a9470ad3d31b2014ae2380a12dda5181818
commit 6b597a9470ad3d31b2014ae2380a12dda5181818
Author: ShengYi Hung <aokblast@FreeBSD.org>
AuthorDate: 2026-09-26 06:42:39 +0000
Commit: ShengYi Hung <aokblast@FreeBSD.org>
CommitDate: 2026-11-01 22:07:40 +0000
uchcom: Set rate to 1 if 0
If userspace provides rate == 0, it causes kernel panic as rate is
directly used as a divident, which cannot be zero. Fix it by set the
rate to 1 if it is passed as 0.
Reviewed by: imp, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59111
(cherry picked from commit 228b1a011660ee1005bc4ab7c97113af8d87fe5c)
---
sys/dev/usb/serial/uchcom.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sys/dev/usb/serial/uchcom.c b/sys/dev/usb/serial/uchcom.c
index ff1ac8897c90..d315b2d37c46 100644
--- a/sys/dev/usb/serial/uchcom.c
+++ b/sys/dev/usb/serial/uchcom.c
@@ -628,6 +628,9 @@ 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) {