This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new c983aee38a driver/serial: fix race condition about calling 
rxflowcontrol in mutli thread
c983aee38a is described below

commit c983aee38abeb528fcda8e3ac8b0ed0c3dd6e2c7
Author: dongjiuzhu1 <[email protected]>
AuthorDate: Tue Aug 29 18:43:49 2023 +0800

    driver/serial: fix race condition about calling rxflowcontrol in mutli 
thread
    
    Signed-off-by: dongjiuzhu1 <[email protected]>
---
 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;
 }
 

Reply via email to