Static analyzer can not see balanced locking if the lock is acquired and released conditionally. Add __acquire() and __release() markings in the right locations so that sparse isn't tripped up on the conditional locking. drivers/tty/serial/serial_core.c:131:17: warning: context imbalance in 'uart_stop' - unexpected unlock include/linux/spinlock.h:362:9: warning: context imbalance in 'uart_start' - unexpected unlock include/linux/spinlock.h:362:9: warning: context imbalance in 'uart_put_char' - unexpected unlock include/linux/spinlock.h:362:9: warning: context imbalance in 'uart_write' - unexpected unlock include/linux/spinlock.h:362:9: warning: context imbalance in 'uart_write_room' - unexpected unlock include/linux/spinlock.h:362:9: warning: context imbalance in 'uart_chars_in_buffer' - unexpected unlock include/linux/spinlock.h:362:9: warning: context imbalance in 'uart_flush_buffer' - unexpected unlock Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> --- drivers/tty/serial/serial_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f2303f3..ff90c8e 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -82,6 +82,8 @@ static inline void uart_port_deref(struct uart_port *uport) struct uart_port *__uport = uart_port_ref(state); \ if (__uport) \ spin_lock_irqsave(&__uport->lock, flags); \ + else \ + __acquire(&__uport->lock); \ __uport; \ }) @@ -90,6 +92,8 @@ static inline void uart_port_deref(struct uart_port *uport) struct uart_port *__uport = uport; \ if (__uport) \ spin_unlock_irqrestore(&__uport->lock, flags); \ + else \ + __release(&__uport->lock); \ uart_port_deref(__uport); \ }) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html