diff options
| author | ShengYi Hung <aokblast@FreeBSD.org> | 2026-09-26 06:42:39 +0000 |
|---|---|---|
| committer | ShengYi Hung <aokblast@FreeBSD.org> | 2026-09-26 06:45:08 +0000 |
| commit | 228b1a011660ee1005bc4ab7c97113af8d87fe5c (patch) | |
| tree | 457ea491e36d7fe8f8a5ec131661a233023a7414 | |
| parent | d8acc2a9a431b4d57ef79b2ca3113ecf33b95d8d (diff) | |
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
| -rw-r--r-- | sys/dev/usb/serial/uchcom.c | 3 |
1 files changed, 3 insertions, 0 deletions
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) { |
