[bug report] serial: 8250: Rate limit serial port rx interrupts during input overruns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Darwin Dingel,

This is a semi-automatic email about new static checker warnings.

The patch 6d7f677a2afa: "serial: 8250: Rate limit serial port rx 
interrupts during input overruns" from Dec 10, 2018, leads to the 
following Smatch complaint:

    drivers/tty/serial/8250/8250_core.c:1077 serial8250_register_8250_port()
    error: we previously assumed 'uart' could be null (see line 984)

drivers/tty/serial/8250/8250_core.c
   983		uart = serial8250_find_match_or_unused(&up->port);
   984		if (uart && uart->port.type != PORT_8250_CIR) {
                    ^^^^
The old code checked for NULL.

   985			if (uart->port.dev)
   986				uart_remove_one_port(&serial8250_reg, &uart->port);
   987	
   988			uart->port.iobase       = up->port.iobase;
   989			uart->port.membase      = up->port.membase;
   990			uart->port.irq          = up->port.irq;
   991			uart->port.irqflags     = up->port.irqflags;
   992			uart->port.uartclk      = up->port.uartclk;
   993			uart->port.fifosize     = up->port.fifosize;
   994			uart->port.regshift     = up->port.regshift;
   995			uart->port.iotype       = up->port.iotype;
   996			uart->port.flags        = up->port.flags | UPF_BOOT_AUTOCONF;
   997			uart->bugs		= up->bugs;
   998			uart->port.mapbase      = up->port.mapbase;
   999			uart->port.mapsize      = up->port.mapsize;
  1000			uart->port.private_data = up->port.private_data;
  1001			uart->tx_loadsz		= up->tx_loadsz;
  1002			uart->capabilities	= up->capabilities;
  1003			uart->port.throttle	= up->port.throttle;
  1004			uart->port.unthrottle	= up->port.unthrottle;
  1005			uart->port.rs485_config	= up->port.rs485_config;
  1006			uart->port.rs485	= up->port.rs485;
  1007			uart->dma		= up->dma;
  1008	
  1009			/* Take tx_loadsz from fifosize if it wasn't set separately */
  1010			if (uart->port.fifosize && !uart->tx_loadsz)
  1011				uart->tx_loadsz = uart->port.fifosize;
  1012	
  1013			if (up->port.dev)
  1014				uart->port.dev = up->port.dev;
  1015	
  1016			if (up->port.flags & UPF_FIXED_TYPE)
  1017				uart->port.type = up->port.type;
  1018	
  1019			serial8250_set_defaults(uart);
  1020	
  1021			/* Possibly override default I/O functions.  */
  1022			if (up->port.serial_in)
  1023				uart->port.serial_in = up->port.serial_in;
  1024			if (up->port.serial_out)
  1025				uart->port.serial_out = up->port.serial_out;
  1026			if (up->port.handle_irq)
  1027				uart->port.handle_irq = up->port.handle_irq;
  1028			/*  Possibly override set_termios call */
  1029			if (up->port.set_termios)
  1030				uart->port.set_termios = up->port.set_termios;
  1031			if (up->port.set_ldisc)
  1032				uart->port.set_ldisc = up->port.set_ldisc;
  1033			if (up->port.get_mctrl)
  1034				uart->port.get_mctrl = up->port.get_mctrl;
  1035			if (up->port.set_mctrl)
  1036				uart->port.set_mctrl = up->port.set_mctrl;
  1037			if (up->port.get_divisor)
  1038				uart->port.get_divisor = up->port.get_divisor;
  1039			if (up->port.set_divisor)
  1040				uart->port.set_divisor = up->port.set_divisor;
  1041			if (up->port.startup)
  1042				uart->port.startup = up->port.startup;
  1043			if (up->port.shutdown)
  1044				uart->port.shutdown = up->port.shutdown;
  1045			if (up->port.pm)
  1046				uart->port.pm = up->port.pm;
  1047			if (up->port.handle_break)
  1048				uart->port.handle_break = up->port.handle_break;
  1049			if (up->dl_read)
  1050				uart->dl_read = up->dl_read;
  1051			if (up->dl_write)
  1052				uart->dl_write = up->dl_write;
  1053	
  1054			if (uart->port.type != PORT_8250_CIR) {
  1055				if (serial8250_isa_config != NULL)
  1056					serial8250_isa_config(0, &uart->port,
  1057							&uart->capabilities);
  1058	
  1059				serial8250_apply_quirks(uart);
  1060				ret = uart_add_one_port(&serial8250_reg,
  1061							&uart->port);
  1062				if (ret == 0)
  1063					ret = uart->port.line;
  1064			} else {
  1065				dev_info(uart->port.dev,
  1066					"skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n",
  1067					uart->port.iobase,
  1068					(unsigned long long)uart->port.mapbase,
  1069					uart->port.irq);
  1070	
  1071				ret = 0;
  1072			}
  1073		}
  1074	
  1075		/* Initialise interrupt backoff work if required */
  1076		if (up->overrun_backoff_time_ms > 0) {
  1077			uart->overrun_backoff_time_ms = up->overrun_backoff_time_ms;
                        ^^^^

  1078			INIT_DELAYED_WORK(&uart->overrun_backoff,
  1079					  serial_8250_overrun_backoff_work);
  1080          } else {
  1081                  uart->overrun_backoff_time_ms = 0;
                        ^^^^^^
The patch adds unchecked dereferences.

  1082          }
  1083  
  1084          mutex_unlock(&serial_mutex);
  1085  
  1086          return ret;
  1087  }


regards,
dan carpenter



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux