From 984b612c48edbbb5999214142a12d318e94d9101 Mon Sep 17 00:00:00 2001 From: Wouter Cappelle Date: Fri, 7 Oct 2022 14:49:16 +0200 Subject: [PATCH] drivers: uart: stm32 async uart driver should free next buffer When disabling async rx, the next buffer is not free-ed by the stm32 uart driver. Signed-off-by: Wouter Cappelle --- drivers/serial/uart_stm32.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index c6db73322fa..228e916921b 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -1129,6 +1129,14 @@ static int uart_stm32_async_rx_disable(const struct device *dev) dma_stop(data->dma_rx.dma_dev, data->dma_rx.dma_channel); + if (data->rx_next_buffer) { + struct uart_event rx_next_buf_release_evt = { + .type = UART_RX_BUF_RELEASED, + .data.rx_buf.buf = data->rx_next_buffer, + }; + async_user_callback(data, &rx_next_buf_release_evt); + } + data->rx_next_buffer = NULL; data->rx_next_buffer_len = 0;