Changeset b38887a in rtems


Ignore:
Timestamp:
Oct 5, 2018, 11:39:49 AM (14 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
8776bb9
Parents:
8352d41
git-author:
Sebastian Huber <sebastian.huber@…> (10/05/18 11:39:49)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/05/18 11:41:06)
Message:

dev/sc16is752: Deal with a baud of zero

Avoid division by zero and instead disable rx/tx in case of a zero baud
value. Problem identified by Coverity Scan.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/dev/serial/sc16is752.c

    r8352d41 rb38887a  
    144144{
    145145  sc16is752_context *ctx = (sc16is752_context *)base;
    146   bool baud_successful;
    147146  rtems_termios_baud_t baud;
    148147
     
    150149
    151150  baud = rtems_termios_baud_to_number(term->c_ospeed);
    152   baud_successful = set_baud(ctx, baud);
    153   if (!baud_successful){
    154     return false;
    155   }
    156 
    157   if ((term->c_cflag & CREAD) == 0){
    158     ctx->efcr |= SC16IS752_EFCR_RX_DISABLE;
    159   } else {
    160     ctx->efcr &= ~SC16IS752_EFCR_RX_DISABLE;
     151
     152  if (baud > 0) {
     153    if (!set_baud(ctx, baud)){
     154      return false;
     155    }
     156
     157    ctx->efcr &= ~SC16IS752_EFCR_TX_DISABLE;
     158
     159    if ((term->c_cflag & CREAD) == 0){
     160      ctx->efcr |= SC16IS752_EFCR_RX_DISABLE;
     161    } else {
     162      ctx->efcr &= ~SC16IS752_EFCR_RX_DISABLE;
     163    }
     164  } else {
     165    ctx->efcr |= SC16IS752_EFCR_RX_DISABLE | SC16IS752_EFCR_TX_DISABLE;
    161166  }
    162167
Note: See TracChangeset for help on using the changeset viewer.