serial: 8250: fix handle_irq locking
Hello Johan Hovold,
The patch 853a9ae29e97: "serial: 8250: fix handle_irq locking" from Jul 14, 2021, leads to the following Smatch static checker warning:
drivers/tty/serial/8250/8250_fsl.c:84 fsl8250_handle_irq() warn: inconsistent returns 'flags'.
Locked on : 38,46
Unlocked on: 84
drivers/tty/serial/8250/8250_fsl.c
26 int fsl8250_handle_irq(struct uart_port *port)
27 {
28 unsigned long flags;
29 u16 lsr, orig_lsr;
30 unsigned int iir;
31 struct uart_8250_port *up = up_to_u8250p(port);
32
33 spin_lock_irqsave(&up->port.lock, flags);
^^^^^
34
35 iir = port->serial_in(port, UART_IIR);
36 if (iir & UART_IIR_NO_INT) {
37 spin_unlock(&up->port.lock);
38 return 0;Needs to enable IRQs again. Same below etc.
39 }
40
41 /* This is the WAR; if last event was BRK, then read and return */
42 if (unlikely(up->lsr_saved_flags & UART_LSR_BI)) {
43 up->lsr_saved_flags &= ~UART_LSR_BI;
44 port->serial_in(port, UART_RX);
45 spin_unlock(&up->port.lock);
46 return 1;
47 }
48 regards,
dan carpenter
Quoted 25 lines · Dan Carpenter
Hello Johan Hovold,
The patch
853a9ae29e97: "serial: 8250: fixhandle_irqlocking" from Jul 14, 2021, leads to the following Smatch static checker warning:
drivers/tty/serial/8250/8250_fsl.c:84fsl8250_handle_irq()warn: inconsistent returns 'flags'.
Locked on : 38,46
Unlocked on: 84
drivers/tty/serial/8250/8250_fsl.c26 int fsl8250_handle_irq(struct uart_port *port) 27 { 28 unsigned long flags; 29 u16 lsr, orig_lsr; 30 unsigned int iir; 31 struct uart_8250_port *up = up_to_u8250p(port); 32 33 spin_lock_irqsave(&up->port.lock, flags); ^^^^^ 34 35 iir = port->serial_in(port, UART_IIR); 36 if (iir & UART_IIR_NO_INT) { 37 spin_unlock(&up->port.lock); 38 return 0;
Quoted 1 line
Needs to enable IRQs again. Same below etc.
Thanks, Dan. I just sent a fix here:
https://lore.kernel.org/r/[email protected]
Johan