driver/serial: fix race condition about calling rxflowcontrol in mutli thread

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1 2023-08-29 18:43:49 +08:00 committed by Xiang Xiao
parent ec4f6ecce2
commit c983aee38a
1 changed files with 2 additions and 0 deletions

View File

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