fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35083?usp=email )
Change subject: soft_uart: check n_bits against 0 in osmo_soft_uart_tx_ubits() ......................................................................
soft_uart: check n_bits against 0 in osmo_soft_uart_tx_ubits()
Currently calling this function with n_ubits == 0 would result in requesting one character from the application (via the .tx_cb()), but not actually transmitting anything. Make it return early.
Change-Id: Icbf99a9f2f6fa64dd71a5f37922f9001577c6c97 Related: OS#4396 --- M src/core/soft_uart.c 1 file changed, 18 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/83/35083/1
diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c index e0f0780..4fffaee 100644 --- a/src/core/soft_uart.c +++ b/src/core/soft_uart.c @@ -24,6 +24,7 @@ #include <stdint.h> #include <errno.h>
+#include <osmocom/core/utils.h> #include <osmocom/core/timer.h> #include <osmocom/core/soft_uart.h>
@@ -286,6 +287,9 @@ size_t n_frame_bits, n_chars; struct msgb *msg = NULL;
+ if (OSMO_UNLIKELY(n_ubits == 0)) + return -EINVAL; + /* calculate UART frame size for the effective config */ n_frame_bits = 1 + cfg->num_data_bits + cfg->num_stop_bits; if (cfg->parity_mode != OSMO_SUART_PARITY_NONE)