[PATCH 1/3] z85c30.c: Do not process 0 baud and return an error (CID 1399713)

Joel Sherrill joel at rtems.org
Thu Mar 14 13:22:31 UTC 2019


---
 bsps/shared/dev/serial/z85c30.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/bsps/shared/dev/serial/z85c30.c b/bsps/shared/dev/serial/z85c30.c
index 55df9d3..d1f4a6f 100644
--- a/bsps/shared/dev/serial/z85c30.c
+++ b/bsps/shared/dev/serial/z85c30.c
@@ -456,6 +456,15 @@ Z85C30_STATIC int z85c30_set_attributes(
   baud_number = (uint32_t) rtems_termios_baud_to_number( baud_requested );
   _Assert( baud_number != 0 );
 
+  /*
+   * POSIX says baud rate of zero is a request to hang up or disconnect.
+   * This is not supported by this driver.
+   */
+  _Assert( baud_number != 0 );
+  if (baud_number == 0) {
+    return -1;
+  }
+
   ulBaudDivisor = Z85C30_Baud(
     (uint32_t) Console_Port_Tbl[minor]->ulClock,
     baud_number
-- 
1.8.3.1



More information about the devel mailing list