Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Aug 2014 10:47:45 +0000 (UTC)
From:      Joerg Wunsch <joerg@svn.freebsd.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r269470 - head/sys/dev/usb/serial
Message-ID:  <53de1351.5c38.22a9a53a@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: joerg
Date: Sun Aug  3 10:47:45 2014
New Revision: 269470
URL: http://svnweb.freebsd.org/changeset/base/269470

Log:
  Avoid a divide-by-zero panic when setting the baudrate to 0.
  
  MFC after:	2 weeks

Modified:
  head/sys/dev/usb/serial/umcs.c

Modified: head/sys/dev/usb/serial/umcs.c
==============================================================================
--- head/sys/dev/usb/serial/umcs.c	Sun Aug  3 10:02:14 2014	(r269469)
+++ head/sys/dev/usb/serial/umcs.c	Sun Aug  3 10:47:45 2014	(r269470)
@@ -1083,7 +1083,10 @@ umcs7840_calc_baudrate(uint32_t rate, ui
 
 	for (i = 0; i < umcs7840_baudrate_divisors_len - 1 &&
 	    !(rate > umcs7840_baudrate_divisors[i] && rate <= umcs7840_baudrate_divisors[i + 1]); ++i);
-	*divisor = umcs7840_baudrate_divisors[i + 1] / rate;
+	if (rate == 0)
+		*divisor = 1;	/* XXX */
+	else
+		*divisor = umcs7840_baudrate_divisors[i + 1] / rate;
 	/* 0x00 .. 0x70 */
 	*clk = i << MCS7840_DEV_SPx_CLOCK_SHIFT;
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53de1351.5c38.22a9a53a>