From 062d4d5e11ac0bf02673fbbb075667497291ef40 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Mon, 15 Jul 2024 12:51:24 -0700 Subject: [PATCH] serial: uart_async_rx: Avoid possible division by zero Ensures that config->but_cnt is not zero. Fixes #66800 CID #338107 Signed-off-by: Flavio Ceolin (cherry picked from commit 5822267c233090aa1953a1851d5388a24bf51a16) --- drivers/serial/uart_async_rx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/serial/uart_async_rx.c b/drivers/serial/uart_async_rx.c index 8ee3fc54af1f8b..00a6749c1238b2 100644 --- a/drivers/serial/uart_async_rx.c +++ b/drivers/serial/uart_async_rx.c @@ -137,6 +137,7 @@ void uart_async_rx_reset(struct uart_async_rx *rx_data) int uart_async_rx_init(struct uart_async_rx *rx_data, const struct uart_async_rx_config *config) { + __ASSERT_NO_MSG(config->buf_cnt > 0); __ASSERT_NO_MSG(config->length / config->buf_cnt <= UINT8_MAX); memset(rx_data, 0, sizeof(*rx_data)); rx_data->config = config;