soft_uart: fix Rx buffer flushing logic in suart_rx_ch()

Whenever we encounter a parity and/or a framing error, we should
call the .rx_cb() immediately, even if this was the first
character in the receive buffer.

Change-Id: I73fab1a5c196d2dbdfe98b0c20d8dadbd22f4f64
Related: OS#4396
diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c
index 400ce5a..058512d 100644
--- a/src/core/soft_uart.c
+++ b/src/core/soft_uart.c
@@ -97,12 +97,13 @@
 	msgb_put_u8(suart->rx.msg, ch);
 	msg_len = msgb_length(suart->rx.msg);
 
-	/* first character in new message: start timer */
-	if (msg_len == 1) {
+	if (msg_len >= suart->cfg.rx_buf_size || suart->rx.flags) {
+		/* either the buffer is full, or we hit a parity and/or a framing error */
+		osmo_soft_uart_flush_rx(suart);
+	} else if (msg_len == 1) {
+		/* first character in new message: start timer */
 		osmo_timer_schedule(&suart->rx.timer, suart->cfg.rx_timeout_ms / 1000,
 				    (suart->cfg.rx_timeout_ms % 1000) * 1000);
-	} else if (msg_len >= suart->cfg.rx_buf_size || suart->rx.flags) {
-		osmo_soft_uart_flush_rx(suart);
 	}
 }