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 <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2024-07-15 12:51:24 -07:00 committed by Anas Nashif
commit 5822267c23

View file

@ -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;