From c983aee38abeb528fcda8e3ac8b0ed0c3dd6e2c7 Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Tue, 29 Aug 2023 18:43:49 +0800 Subject: [PATCH] driver/serial: fix race condition about calling rxflowcontrol in mutli thread Signed-off-by: dongjiuzhu1 --- drivers/serial/uart_rpmsg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/serial/uart_rpmsg.c b/drivers/serial/uart_rpmsg.c index 7cc1587db7..97c7dd3ef3 100644 --- a/drivers/serial/uart_rpmsg.c +++ b/drivers/serial/uart_rpmsg.c @@ -161,6 +161,7 @@ static bool uart_rpmsg_rxflowcontrol(FAR struct uart_dev_s *dev, FAR struct uart_rpmsg_priv_s *priv = dev->priv; FAR struct uart_rpmsg_wakeup_s msg; + nxmutex_lock(&priv->lock); if (!upper && upper != priv->last_upper) { memset(&msg, 0, sizeof(msg)); @@ -173,6 +174,7 @@ static bool uart_rpmsg_rxflowcontrol(FAR struct uart_dev_s *dev, } priv->last_upper = upper; + nxmutex_unlock(&priv->lock); return false; }